Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / ElementsPanel.js
1 WebInspector.DOMSyntaxHighlighter=function(mimeType,stripExtraWhitespace)
2 {this._mimeType=mimeType;this._stripExtraWhitespace=stripExtraWhitespace;}
3 WebInspector.DOMSyntaxHighlighter.prototype={createSpan:function(content,className)
4 {var span=document.createElement("span");span.className="cm-"+className;if(this._stripExtraWhitespace&&className!=="whitespace")
5 content=content.replace(/^[\n\r]*/,"").replace(/\s*$/,"");span.appendChild(document.createTextNode(content));return span;},syntaxHighlightNode:function(node)
6 {var lines=node.textContent.split("\n");node.removeChildren();function processToken(token,tokenType,column,newColumn)
7 {if(!tokenType)
8 return;if(column>plainTextStart){var plainText=line.substring(plainTextStart,column);node.appendChild(document.createTextNode(plainText));}
9 node.appendChild(this.createSpan(token,tokenType));plainTextStart=newColumn;}
10 var tokenize=WebInspector.moduleManager.instance(WebInspector.TokenizerFactory).createTokenizer(this._mimeType);for(var i=lines[0].length?0:1;i<lines.length;++i){var line=lines[i];var plainTextStart=0;tokenize(line,processToken.bind(this));if(plainTextStart<line.length){var plainText=line.substring(plainTextStart,line.length);node.appendChild(document.createTextNode(plainText));}
11 if(i<lines.length-1)
12 node.appendChild(document.createElement("br"));}}};WebInspector.ElementsTreeOutline=function(omitRootDOMNode,selectEnabled,contextMenuCallback,setPseudoClassCallback)
13 {this.element=document.createElement("ol");this.element.className="elements-tree-outline";this.element.addEventListener("mousedown",this._onmousedown.bind(this),false);this.element.addEventListener("mousemove",this._onmousemove.bind(this),false);this.element.addEventListener("mouseout",this._onmouseout.bind(this),false);this.element.addEventListener("dragstart",this._ondragstart.bind(this),false);this.element.addEventListener("dragover",this._ondragover.bind(this),false);this.element.addEventListener("dragleave",this._ondragleave.bind(this),false);this.element.addEventListener("drop",this._ondrop.bind(this),false);this.element.addEventListener("dragend",this._ondragend.bind(this),false);this.element.addEventListener("keydown",this._onkeydown.bind(this),false);TreeOutline.call(this,this.element);this._includeRootDOMNode=!omitRootDOMNode;this._selectEnabled=selectEnabled;this._rootDOMNode=null;this._selectedDOMNode=null;this._eventSupport=new WebInspector.Object();this._visible=false;this.element.addEventListener("contextmenu",this._contextMenuEventFired.bind(this),true);this._contextMenuCallback=contextMenuCallback;this._setPseudoClassCallback=setPseudoClassCallback;this._createNodeDecorators();}
14 WebInspector.ElementsTreeOutline.Events={SelectedNodeChanged:"SelectedNodeChanged",ElementsTreeUpdated:"ElementsTreeUpdated"}
15 WebInspector.ElementsTreeOutline.MappedCharToEntity={"\u00a0":"nbsp","\u2002":"ensp","\u2003":"emsp","\u2009":"thinsp","\u200a":"#8202","\u200b":"#8203","\u200c":"zwnj","\u200d":"zwj","\u200e":"lrm","\u200f":"rlm","\u202a":"#8234","\u202b":"#8235","\u202c":"#8236","\u202d":"#8237","\u202e":"#8238"}
16 WebInspector.ElementsTreeOutline.prototype={setVisibleWidth:function(width)
17 {this._visibleWidth=width;if(this._multilineEditing)
18 this._multilineEditing.setWidth(this._visibleWidth);},_createNodeDecorators:function()
19 {this._nodeDecorators=[];this._nodeDecorators.push(new WebInspector.ElementsTreeOutline.PseudoStateDecorator());},wireToDomAgent:function()
20 {this._elementsTreeUpdater=new WebInspector.ElementsTreeUpdater(this);},setVisible:function(visible)
21 {this._visible=visible;if(!this._visible)
22 return;this._updateModifiedNodes();if(this._selectedDOMNode)
23 this._revealAndSelectNode(this._selectedDOMNode,false);},addEventListener:function(eventType,listener,thisObject)
24 {this._eventSupport.addEventListener(eventType,listener,thisObject);},removeEventListener:function(eventType,listener,thisObject)
25 {this._eventSupport.removeEventListener(eventType,listener,thisObject);},get rootDOMNode()
26 {return this._rootDOMNode;},set rootDOMNode(x)
27 {if(this._rootDOMNode===x)
28 return;this._rootDOMNode=x;this._isXMLMimeType=x&&x.isXMLNode();this.update();},get isXMLMimeType()
29 {return this._isXMLMimeType;},selectedDOMNode:function()
30 {return this._selectedDOMNode;},selectDOMNode:function(node,focus)
31 {if(this._selectedDOMNode===node){this._revealAndSelectNode(node,!focus);return;}
32 this._selectedDOMNode=node;this._revealAndSelectNode(node,!focus);if(this._selectedDOMNode===node)
33 this._selectedNodeChanged();},editing:function()
34 {var node=this.selectedDOMNode();if(!node)
35 return false;var treeElement=this.findTreeElement(node);if(!treeElement)
36 return false;return treeElement._editing||false;},update:function()
37 {var selectedNode=this.selectedTreeElement?this.selectedTreeElement._node:null;this.removeChildren();if(!this.rootDOMNode)
38 return;var treeElement;if(this._includeRootDOMNode){treeElement=new WebInspector.ElementsTreeElement(this.rootDOMNode);treeElement.selectable=this._selectEnabled;this.appendChild(treeElement);}else{var node=this.rootDOMNode.firstChild;while(node){treeElement=new WebInspector.ElementsTreeElement(node);treeElement.selectable=this._selectEnabled;this.appendChild(treeElement);node=node.nextSibling;}}
39 if(selectedNode)
40 this._revealAndSelectNode(selectedNode,true);},updateSelection:function()
41 {if(!this.selectedTreeElement)
42 return;var element=this.treeOutline.selectedTreeElement;element.updateSelection();},updateOpenCloseTags:function(node)
43 {var treeElement=this.findTreeElement(node);if(treeElement)
44 treeElement.updateTitle();var children=treeElement.children;var closingTagElement=children[children.length-1];if(closingTagElement&&closingTagElement._elementCloseTag)
45 closingTagElement.updateTitle();},_selectedNodeChanged:function()
46 {this._eventSupport.dispatchEventToListeners(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged,this._selectedDOMNode);},_fireElementsTreeUpdated:function(nodes)
47 {this._eventSupport.dispatchEventToListeners(WebInspector.ElementsTreeOutline.Events.ElementsTreeUpdated,nodes);},findTreeElement:function(node)
48 {function isAncestorNode(ancestor,node)
49 {return ancestor.isAncestor(node);}
50 function parentNode(node)
51 {return node.parentNode;}
52 var treeElement=TreeOutline.prototype.findTreeElement.call(this,node,isAncestorNode,parentNode);if(!treeElement&&node.nodeType()===Node.TEXT_NODE){treeElement=TreeOutline.prototype.findTreeElement.call(this,node.parentNode,isAncestorNode,parentNode);}
53 return treeElement;},createTreeElementFor:function(node)
54 {var treeElement=this.findTreeElement(node);if(treeElement)
55 return treeElement;if(!node.parentNode)
56 return null;treeElement=this.createTreeElementFor(node.parentNode);return treeElement?treeElement._showChild(node):null;},set suppressRevealAndSelect(x)
57 {if(this._suppressRevealAndSelect===x)
58 return;this._suppressRevealAndSelect=x;},_revealAndSelectNode:function(node,omitFocus)
59 {if(this._suppressRevealAndSelect)
60 return;if(!this._includeRootDOMNode&&node===this.rootDOMNode&&this.rootDOMNode)
61 node=this.rootDOMNode.firstChild;if(!node)
62 return;var treeElement=this.createTreeElementFor(node);if(!treeElement)
63 return;treeElement.revealAndSelect(omitFocus);},_treeElementFromEvent:function(event)
64 {var scrollContainer=this.element.parentElement;var x=scrollContainer.totalOffsetLeft()+scrollContainer.offsetWidth-36;var y=event.pageY;var elementUnderMouse=this.treeElementFromPoint(x,y);var elementAboveMouse=this.treeElementFromPoint(x,y-2);var element;if(elementUnderMouse===elementAboveMouse)
65 element=elementUnderMouse;else
66 element=this.treeElementFromPoint(x,y+2);return element;},_onmousedown:function(event)
67 {var element=this._treeElementFromEvent(event);if(!element||element.isEventWithinDisclosureTriangle(event))
68 return;element.select();},_onmousemove:function(event)
69 {var element=this._treeElementFromEvent(event);if(element&&this._previousHoveredElement===element)
70 return;if(this._previousHoveredElement){this._previousHoveredElement.hovered=false;delete this._previousHoveredElement;}
71 if(element){element.hovered=true;this._previousHoveredElement=element;}
72 WebInspector.domModel.highlightDOMNode(element&&element._node?element._node.id:0);},_onmouseout:function(event)
73 {var nodeUnderMouse=document.elementFromPoint(event.pageX,event.pageY);if(nodeUnderMouse&&nodeUnderMouse.isDescendant(this.element))
74 return;if(this._previousHoveredElement){this._previousHoveredElement.hovered=false;delete this._previousHoveredElement;}
75 WebInspector.domModel.hideDOMNodeHighlight();},_ondragstart:function(event)
76 {if(!window.getSelection().isCollapsed)
77 return false;if(event.target.nodeName==="A")
78 return false;var treeElement=this._treeElementFromEvent(event);if(!treeElement)
79 return false;if(!this._isValidDragSourceOrTarget(treeElement))
80 return false;if(treeElement._node.nodeName()==="BODY"||treeElement._node.nodeName()==="HEAD")
81 return false;event.dataTransfer.setData("text/plain",treeElement.listItemElement.textContent);event.dataTransfer.effectAllowed="copyMove";this._treeElementBeingDragged=treeElement;WebInspector.domModel.hideDOMNodeHighlight();return true;},_ondragover:function(event)
82 {if(!this._treeElementBeingDragged)
83 return false;var treeElement=this._treeElementFromEvent(event);if(!this._isValidDragSourceOrTarget(treeElement))
84 return false;var node=treeElement._node;while(node){if(node===this._treeElementBeingDragged._node)
85 return false;node=node.parentNode;}
86 treeElement.updateSelection();treeElement.listItemElement.classList.add("elements-drag-over");this._dragOverTreeElement=treeElement;event.preventDefault();event.dataTransfer.dropEffect='move';return false;},_ondragleave:function(event)
87 {this._clearDragOverTreeElementMarker();event.preventDefault();return false;},_isValidDragSourceOrTarget:function(treeElement)
88 {if(!treeElement)
89 return false;var node=treeElement.representedObject;if(!(node instanceof WebInspector.DOMNode))
90 return false;if(!node.parentNode||node.parentNode.nodeType()!==Node.ELEMENT_NODE)
91 return false;return true;},_ondrop:function(event)
92 {event.preventDefault();var treeElement=this._treeElementFromEvent(event);if(treeElement)
93 this._doMove(treeElement);},_doMove:function(treeElement)
94 {if(!this._treeElementBeingDragged)
95 return;var parentNode;var anchorNode;if(treeElement._elementCloseTag){parentNode=treeElement._node;}else{var dragTargetNode=treeElement._node;parentNode=dragTargetNode.parentNode;anchorNode=dragTargetNode;}
96 var wasExpanded=this._treeElementBeingDragged.expanded;this._treeElementBeingDragged._node.moveTo(parentNode,anchorNode,this._selectNodeAfterEdit.bind(this,wasExpanded));delete this._treeElementBeingDragged;},_ondragend:function(event)
97 {event.preventDefault();this._clearDragOverTreeElementMarker();delete this._treeElementBeingDragged;},_clearDragOverTreeElementMarker:function()
98 {if(this._dragOverTreeElement){this._dragOverTreeElement.updateSelection();this._dragOverTreeElement.listItemElement.classList.remove("elements-drag-over");delete this._dragOverTreeElement;}},_onkeydown:function(event)
99 {var keyboardEvent=(event);var node=(this.selectedDOMNode());console.assert(node);var treeElement=this.getCachedTreeElement(node);if(!treeElement)
100 return;if(!treeElement._editing&&WebInspector.KeyboardShortcut.hasNoModifiers(keyboardEvent)&&keyboardEvent.keyCode===WebInspector.KeyboardShortcut.Keys.H.code){this._toggleHideShortcut(node);event.consume(true);return;}},_contextMenuEventFired:function(event)
101 {var treeElement=this._treeElementFromEvent(event);if(!treeElement)
102 return;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApplicableItems(treeElement._node);contextMenu.show();},populateContextMenu:function(contextMenu,event)
103 {var treeElement=this._treeElementFromEvent(event);if(!treeElement)
104 return;var isPseudoElement=!!treeElement._node.pseudoType();var isTag=treeElement._node.nodeType()===Node.ELEMENT_NODE&&!isPseudoElement;var textNode=event.target.enclosingNodeOrSelfWithClass("webkit-html-text-node");if(textNode&&textNode.classList.contains("bogus"))
105 textNode=null;var commentNode=event.target.enclosingNodeOrSelfWithClass("webkit-html-comment");contextMenu.appendApplicableItems(event.target);if(textNode){contextMenu.appendSeparator();treeElement._populateTextContextMenu(contextMenu,textNode);}else if(isTag){contextMenu.appendSeparator();treeElement._populateTagContextMenu(contextMenu,event);}else if(commentNode){contextMenu.appendSeparator();treeElement._populateNodeContextMenu(contextMenu,textNode);}else if(isPseudoElement){treeElement._populateScrollIntoView(contextMenu);}else if(treeElement._node.isShadowRoot()){this.treeOutline._populateContextMenu(contextMenu,treeElement._node);}},_updateModifiedNodes:function()
106 {if(this._elementsTreeUpdater)
107 this._elementsTreeUpdater._updateModifiedNodes();},_populateContextMenu:function(contextMenu,node)
108 {if(this._contextMenuCallback)
109 this._contextMenuCallback(contextMenu,node);},handleShortcut:function(event)
110 {var node=this.selectedDOMNode();var treeElement=this.getCachedTreeElement(node);if(!node||!treeElement)
111 return;if(event.keyIdentifier==="F2"&&treeElement.hasEditableNode()){this._toggleEditAsHTML(node);event.handled=true;return;}
112 if(WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)&&node.parentNode){if(event.keyIdentifier==="Up"&&node.previousSibling){node.moveTo(node.parentNode,node.previousSibling,this._selectNodeAfterEdit.bind(this,treeElement.expanded));event.handled=true;return;}
113 if(event.keyIdentifier==="Down"&&node.nextSibling){node.moveTo(node.parentNode,node.nextSibling.nextSibling,this._selectNodeAfterEdit.bind(this,treeElement.expanded));event.handled=true;return;}}},_toggleEditAsHTML:function(node)
114 {var treeElement=this.getCachedTreeElement(node);if(!treeElement)
115 return;if(treeElement._editing&&treeElement._htmlEditElement&&WebInspector.isBeingEdited(treeElement._htmlEditElement))
116 treeElement._editing.commit();else
117 treeElement._editAsHTML();},_selectNodeAfterEdit:function(wasExpanded,error,nodeId)
118 {if(error)
119 return;this._updateModifiedNodes();var newNode=nodeId?WebInspector.domModel.nodeForId(nodeId):null;if(!newNode)
120 return;this.selectDOMNode(newNode,true);var newTreeItem=this.findTreeElement(newNode);if(wasExpanded){if(newTreeItem)
121 newTreeItem.expand();}
122 return newTreeItem;},_toggleHideShortcut:function(node,userCallback)
123 {var pseudoType=node.pseudoType();var effectiveNode=pseudoType?node.parentNode:node;if(!effectiveNode)
124 return;function resolvedNode(object)
125 {if(!object)
126 return;function toggleClassAndInjectStyleRule(pseudoType)
127 {const classNamePrefix="__web-inspector-hide";const classNameSuffix="-shortcut__";const styleTagId="__web-inspector-hide-shortcut-style__";const styleRules=".__web-inspector-hide-shortcut__, .__web-inspector-hide-shortcut__ * { visibility: hidden !important; } .__web-inspector-hidebefore-shortcut__::before { visibility: hidden !important; } .__web-inspector-hideafter-shortcut__::after { visibility: hidden !important; }";var className=classNamePrefix+(pseudoType||"")+classNameSuffix;this.classList.toggle(className);var style=document.head.querySelector("style#"+styleTagId);if(style)
128 return;style=document.createElement("style");style.id=styleTagId;style.type="text/css";style.textContent=styleRules;document.head.appendChild(style);}
129 object.callFunction(toggleClassAndInjectStyleRule,[{value:pseudoType}],userCallback);object.release();}
130 WebInspector.RemoteObject.resolveNode(effectiveNode,"",resolvedNode);},__proto__:TreeOutline.prototype}
131 WebInspector.ElementsTreeOutline.ElementDecorator=function()
132 {}
133 WebInspector.ElementsTreeOutline.ElementDecorator.prototype={decorate:function(node)
134 {},decorateAncestor:function(node)
135 {}}
136 WebInspector.ElementsTreeOutline.PseudoStateDecorator=function()
137 {WebInspector.ElementsTreeOutline.ElementDecorator.call(this);}
138 WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName="pseudoState";WebInspector.ElementsTreeOutline.PseudoStateDecorator.prototype={decorate:function(node)
139 {if(node.nodeType()!==Node.ELEMENT_NODE)
140 return null;var propertyValue=node.getUserProperty(WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName);if(!propertyValue)
141 return null;return WebInspector.UIString("Element state: %s",":"+propertyValue.join(", :"));},decorateAncestor:function(node)
142 {if(node.nodeType()!==Node.ELEMENT_NODE)
143 return null;var descendantCount=node.descendantUserPropertyCount(WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName);if(!descendantCount)
144 return null;if(descendantCount===1)
145 return WebInspector.UIString("%d descendant with forced state",descendantCount);return WebInspector.UIString("%d descendants with forced state",descendantCount);}}
146 WebInspector.ElementsTreeElement=function(node,elementCloseTag)
147 {TreeElement.call(this,"",node);this._node=node;this._elementCloseTag=elementCloseTag;this._updateHasChildren();if(this._node.nodeType()==Node.ELEMENT_NODE&&!elementCloseTag)
148 this._canAddAttributes=true;this._searchQuery=null;this._expandedChildrenLimit=WebInspector.ElementsTreeElement.InitialChildrenLimit;}
149 WebInspector.ElementsTreeElement.InitialChildrenLimit=500;WebInspector.ElementsTreeElement.ForbiddenClosingTagElements=["area","base","basefont","br","canvas","col","command","embed","frame","hr","img","input","keygen","link","meta","param","source"].keySet();WebInspector.ElementsTreeElement.EditTagBlacklist=["html","head","body"].keySet();WebInspector.ElementsTreeElement.prototype={highlightSearchResults:function(searchQuery)
150 {if(this._searchQuery!==searchQuery){this._updateSearchHighlight(false);delete this._highlightResult;}
151 this._searchQuery=searchQuery;this._searchHighlightsVisible=true;this.updateTitle(true);},hideSearchHighlights:function()
152 {delete this._searchHighlightsVisible;this._updateSearchHighlight(false);},_updateSearchHighlight:function(show)
153 {if(!this._highlightResult)
154 return;function updateEntryShow(entry)
155 {switch(entry.type){case"added":entry.parent.insertBefore(entry.node,entry.nextSibling);break;case"changed":entry.node.textContent=entry.newText;break;}}
156 function updateEntryHide(entry)
157 {switch(entry.type){case"added":entry.node.remove();break;case"changed":entry.node.textContent=entry.oldText;break;}}
158 if(show){for(var i=0,size=this._highlightResult.length;i<size;++i)
159 updateEntryShow(this._highlightResult[i]);}else{for(var i=(this._highlightResult.length-1);i>=0;--i)
160 updateEntryHide(this._highlightResult[i]);}},get hovered()
161 {return this._hovered;},set hovered(x)
162 {if(this._hovered===x)
163 return;this._hovered=x;if(this.listItemElement){if(x){this.updateSelection();this.listItemElement.classList.add("hovered");}else{this.listItemElement.classList.remove("hovered");}}},get expandedChildrenLimit()
164 {return this._expandedChildrenLimit;},set expandedChildrenLimit(x)
165 {if(this._expandedChildrenLimit===x)
166 return;this._expandedChildrenLimit=x;if(this.treeOutline&&!this._updateChildrenInProgress)
167 this._updateChildren(true);},get expandedChildCount()
168 {var count=this.children.length;if(count&&this.children[count-1]._elementCloseTag)
169 count--;if(count&&this.children[count-1].expandAllButton)
170 count--;return count;},_showChild:function(child)
171 {if(this._elementCloseTag)
172 return null;var index=this._visibleChildren().indexOf(child);if(index===-1)
173 return null;if(index>=this.expandedChildrenLimit){this._expandedChildrenLimit=index+1;this._updateChildren(true);}
174 return this.expandedChildCount>index?this.children[index]:null;},updateSelection:function()
175 {var listItemElement=this.listItemElement;if(!listItemElement)
176 return;if(!this._readyToUpdateSelection){if(document.body.offsetWidth>0)
177 this._readyToUpdateSelection=true;else{return;}}
178 if(!this.selectionElement){this.selectionElement=document.createElement("div");this.selectionElement.className="selection selected";listItemElement.insertBefore(this.selectionElement,listItemElement.firstChild);}
179 this.selectionElement.style.height=listItemElement.offsetHeight+"px";},onattach:function()
180 {if(this._hovered){this.updateSelection();this.listItemElement.classList.add("hovered");}
181 this.updateTitle();this._preventFollowingLinksOnDoubleClick();this.listItemElement.draggable=true;},_preventFollowingLinksOnDoubleClick:function()
182 {var links=this.listItemElement.querySelectorAll("li .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li .webkit-html-tag > .webkit-html-attribute > .webkit-html-resource-link");if(!links)
183 return;for(var i=0;i<links.length;++i)
184 links[i].preventFollowOnDoubleClick=true;},onpopulate:function()
185 {if(this.children.length||this._showInlineText()||this._elementCloseTag)
186 return;this.updateChildren();},updateChildren:function(fullRefresh)
187 {if(this._elementCloseTag)
188 return;this._node.getChildNodes(this._updateChildren.bind(this,fullRefresh));},insertChildElement:function(child,index,closingTag)
189 {var newElement=new WebInspector.ElementsTreeElement(child,closingTag);newElement.selectable=this.treeOutline._selectEnabled;this.insertChild(newElement,index);return newElement;},moveChild:function(child,targetIndex)
190 {var wasSelected=child.selected;this.removeChild(child);this.insertChild(child,targetIndex);if(wasSelected)
191 child.select();},_updateChildren:function(fullRefresh)
192 {if(this._updateChildrenInProgress||!this.treeOutline._visible)
193 return;this._updateChildrenInProgress=true;var selectedNode=this.treeOutline.selectedDOMNode();var originalScrollTop=0;if(fullRefresh){var treeOutlineContainerElement=this.treeOutline.element.parentNode;originalScrollTop=treeOutlineContainerElement.scrollTop;var selectedTreeElement=this.treeOutline.selectedTreeElement;if(selectedTreeElement&&selectedTreeElement.hasAncestor(this))
194 this.select();this.removeChildren();}
195 function updateChildrenOfNode()
196 {var treeOutline=this.treeOutline;var visibleChildren=this._visibleChildren();var treeChildIndex=0;var elementToSelect=null;for(var i=0;i<visibleChildren.length;++i){var child=visibleChildren[i];var currentTreeElement=this.children[treeChildIndex];if(!currentTreeElement||currentTreeElement._node!==child){var existingTreeElement=null;for(var j=(treeChildIndex+1),size=this.expandedChildCount;j<size;++j){if(this.children[j]._node===child){existingTreeElement=this.children[j];break;}}
197 if(existingTreeElement&&existingTreeElement.parent===this){this.moveChild(existingTreeElement,treeChildIndex);}else{if(treeChildIndex<this.expandedChildrenLimit){var newElement=this.insertChildElement(child,treeChildIndex);if(child===selectedNode)
198 elementToSelect=newElement;if(this.expandedChildCount>this.expandedChildrenLimit)
199 this.expandedChildrenLimit++;}}}
200 ++treeChildIndex;}
201 return elementToSelect;}
202 for(var i=(this.children.length-1);i>=0;--i){var currentChild=this.children[i];var currentNode=currentChild._node;if(!currentNode)
203 continue;var currentParentNode=currentNode.parentNode;if(currentParentNode===this._node)
204 continue;var selectedTreeElement=this.treeOutline.selectedTreeElement;if(selectedTreeElement&&(selectedTreeElement===currentChild||selectedTreeElement.hasAncestor(currentChild)))
205 this.select();this.removeChildAtIndex(i);}
206 var elementToSelect=updateChildrenOfNode.call(this);this.updateTitle();this._adjustCollapsedRange();var lastChild=this.children[this.children.length-1];if(this._node.nodeType()==Node.ELEMENT_NODE&&(!lastChild||!lastChild._elementCloseTag))
207 this.insertChildElement(this._node,this.children.length,true);if(fullRefresh&&elementToSelect){elementToSelect.select();if(treeOutlineContainerElement&&originalScrollTop<=treeOutlineContainerElement.scrollHeight)
208 treeOutlineContainerElement.scrollTop=originalScrollTop;}
209 delete this._updateChildrenInProgress;},_adjustCollapsedRange:function()
210 {var visibleChildren=this._visibleChildren();if(this.expandAllButtonElement&&this.expandAllButtonElement.__treeElement.parent)
211 this.removeChild(this.expandAllButtonElement.__treeElement);const childNodeCount=visibleChildren.length;for(var i=this.expandedChildCount,limit=Math.min(this.expandedChildrenLimit,childNodeCount);i<limit;++i)
212 this.insertChildElement(visibleChildren[i],i);const expandedChildCount=this.expandedChildCount;if(childNodeCount>this.expandedChildCount){var targetButtonIndex=expandedChildCount;if(!this.expandAllButtonElement){var button=document.createElement("button");button.className="show-all-nodes";button.value="";var item=new TreeElement(button,null,false);item.selectable=false;item.expandAllButton=true;this.insertChild(item,targetButtonIndex);this.expandAllButtonElement=item.listItemElement.firstChild;this.expandAllButtonElement.__treeElement=item;this.expandAllButtonElement.addEventListener("click",this.handleLoadAllChildren.bind(this),false);}else if(!this.expandAllButtonElement.__treeElement.parent)
213 this.insertChild(this.expandAllButtonElement.__treeElement,targetButtonIndex);this.expandAllButtonElement.textContent=WebInspector.UIString("Show All Nodes (%d More)",childNodeCount-expandedChildCount);}else if(this.expandAllButtonElement)
214 delete this.expandAllButtonElement;},handleLoadAllChildren:function()
215 {this.expandedChildrenLimit=Math.max(this._visibleChildCount(),this.expandedChildrenLimit+WebInspector.ElementsTreeElement.InitialChildrenLimit);},expandRecursively:function()
216 {function callback()
217 {TreeElement.prototype.expandRecursively.call(this,Number.MAX_VALUE);}
218 this._node.getSubtree(-1,callback.bind(this));},onexpand:function()
219 {if(this._elementCloseTag)
220 return;this.updateTitle();this.treeOutline.updateSelection();},oncollapse:function()
221 {if(this._elementCloseTag)
222 return;this.updateTitle();this.treeOutline.updateSelection();},onreveal:function()
223 {if(this.listItemElement){var tagSpans=this.listItemElement.getElementsByClassName("webkit-html-tag-name");if(tagSpans.length)
224 tagSpans[0].scrollIntoViewIfNeeded(true);else
225 this.listItemElement.scrollIntoViewIfNeeded(true);}},onselect:function(selectedByUser)
226 {this.treeOutline.suppressRevealAndSelect=true;this.treeOutline.selectDOMNode(this._node,selectedByUser);if(selectedByUser)
227 WebInspector.domModel.highlightDOMNode(this._node.id);this.updateSelection();this.treeOutline.suppressRevealAndSelect=false;return true;},ondelete:function()
228 {var startTagTreeElement=this.treeOutline.findTreeElement(this._node);startTagTreeElement?startTagTreeElement.remove():this.remove();return true;},onenter:function()
229 {if(this._editing)
230 return false;this._startEditing();return true;},selectOnMouseDown:function(event)
231 {TreeElement.prototype.selectOnMouseDown.call(this,event);if(this._editing)
232 return;if(this.treeOutline._showInElementsPanelEnabled){WebInspector.inspectorView.showPanel("elements");this.treeOutline.selectDOMNode(this._node,true);}
233 if(event.detail>=2)
234 event.preventDefault();},ondblclick:function(event)
235 {if(this._editing||this._elementCloseTag)
236 return false;if(this._startEditingTarget(event.target))
237 return false;if(this.hasChildren&&!this.expanded)
238 this.expand();return false;},hasEditableNode:function()
239 {return!this.representedObject.isShadowRoot()&&!this.representedObject.ancestorUserAgentShadowRoot();},_insertInLastAttributePosition:function(tag,node)
240 {if(tag.getElementsByClassName("webkit-html-attribute").length>0)
241 tag.insertBefore(node,tag.lastChild);else{var nodeName=tag.textContent.match(/^<(.*?)>$/)[1];tag.textContent='';tag.appendChild(document.createTextNode('<'+nodeName));tag.appendChild(node);tag.appendChild(document.createTextNode('>'));}
242 this.updateSelection();},_startEditingTarget:function(eventTarget)
243 {if(this.treeOutline.selectedDOMNode()!=this._node)
244 return;if(this._node.nodeType()!=Node.ELEMENT_NODE&&this._node.nodeType()!=Node.TEXT_NODE)
245 return false;var textNode=eventTarget.enclosingNodeOrSelfWithClass("webkit-html-text-node");if(textNode)
246 return this._startEditingTextNode(textNode);var attribute=eventTarget.enclosingNodeOrSelfWithClass("webkit-html-attribute");if(attribute)
247 return this._startEditingAttribute(attribute,eventTarget);var tagName=eventTarget.enclosingNodeOrSelfWithClass("webkit-html-tag-name");if(tagName)
248 return this._startEditingTagName(tagName);var newAttribute=eventTarget.enclosingNodeOrSelfWithClass("add-attribute");if(newAttribute)
249 return this._addNewAttribute();return false;},_populateTagContextMenu:function(contextMenu,event)
250 {var treeElement=this._elementCloseTag?this.treeOutline.findTreeElement(this._node):this;contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add attribute":"Add Attribute"),treeElement._addNewAttribute.bind(treeElement));var attribute=event.target.enclosingNodeOrSelfWithClass("webkit-html-attribute");var newAttribute=event.target.enclosingNodeOrSelfWithClass("add-attribute");if(attribute&&!newAttribute)
251 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Edit attribute":"Edit Attribute"),this._startEditingAttribute.bind(this,attribute,event.target));contextMenu.appendSeparator();if(this.treeOutline._setPseudoClassCallback){var pseudoSubMenu=contextMenu.appendSubMenuItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Force element state":"Force Element State"));this._populateForcedPseudoStateItems(pseudoSubMenu);contextMenu.appendSeparator();}
252 this._populateNodeContextMenu(contextMenu);this.treeOutline._populateContextMenu(contextMenu,this._node);this._populateScrollIntoView(contextMenu);},_populateScrollIntoView:function(contextMenu)
253 {contextMenu.appendSeparator();contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Scroll into view":"Scroll into View"),this._scrollIntoView.bind(this));},_populateForcedPseudoStateItems:function(subMenu)
254 {const pseudoClasses=["active","hover","focus","visited"];var node=this._node;var forcedPseudoState=(node?node.getUserProperty("pseudoState"):null)||[];for(var i=0;i<pseudoClasses.length;++i){var pseudoClassForced=forcedPseudoState.indexOf(pseudoClasses[i])>=0;subMenu.appendCheckboxItem(":"+pseudoClasses[i],this.treeOutline._setPseudoClassCallback.bind(null,node.id,pseudoClasses[i],!pseudoClassForced),pseudoClassForced,false);}},_populateTextContextMenu:function(contextMenu,textNode)
255 {contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Edit text":"Edit Text"),this._startEditingTextNode.bind(this,textNode));this._populateNodeContextMenu(contextMenu);},_populateNodeContextMenu:function(contextMenu)
256 {var openTagElement=this.treeOutline.getCachedTreeElement(this.representedObject)||this;var isEditable=this.hasEditableNode();if(isEditable)
257 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"),openTagElement._editAsHTML.bind(openTagElement));var isShadowRoot=this.representedObject.isShadowRoot();if(!isShadowRoot)
258 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"),this._copyHTML.bind(this));if(this.representedObject.nodeType()===Node.ELEMENT_NODE)
259 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Copy CSS path":"Copy CSS Path"),this._copyCSSPath.bind(this));if(!isShadowRoot)
260 contextMenu.appendItem(WebInspector.UIString("Copy XPath"),this._copyXPath.bind(this));if(isEditable)
261 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Delete node":"Delete Node"),this.remove.bind(this));},_startEditing:function()
262 {if(this.treeOutline.selectedDOMNode()!==this._node)
263 return;var listItem=this._listItemNode;if(this._canAddAttributes){var attribute=listItem.getElementsByClassName("webkit-html-attribute")[0];if(attribute)
264 return this._startEditingAttribute(attribute,attribute.getElementsByClassName("webkit-html-attribute-value")[0]);return this._addNewAttribute();}
265 if(this._node.nodeType()===Node.TEXT_NODE){var textNode=listItem.getElementsByClassName("webkit-html-text-node")[0];if(textNode)
266 return this._startEditingTextNode(textNode);return;}},_addNewAttribute:function()
267 {var container=document.createElement("span");this._buildAttributeDOM(container," ","");var attr=container.firstElementChild;attr.style.marginLeft="2px";attr.style.marginRight="2px";var tag=this.listItemElement.getElementsByClassName("webkit-html-tag")[0];this._insertInLastAttributePosition(tag,attr);attr.scrollIntoViewIfNeeded(true);return this._startEditingAttribute(attr,attr);},_triggerEditAttribute:function(attributeName)
268 {var attributeElements=this.listItemElement.getElementsByClassName("webkit-html-attribute-name");for(var i=0,len=attributeElements.length;i<len;++i){if(attributeElements[i].textContent===attributeName){for(var elem=attributeElements[i].nextSibling;elem;elem=elem.nextSibling){if(elem.nodeType!==Node.ELEMENT_NODE)
269 continue;if(elem.classList.contains("webkit-html-attribute-value"))
270 return this._startEditingAttribute(elem.parentNode,elem);}}}},_startEditingAttribute:function(attribute,elementForSelection)
271 {if(WebInspector.isBeingEdited(attribute))
272 return true;var attributeNameElement=attribute.getElementsByClassName("webkit-html-attribute-name")[0];if(!attributeNameElement)
273 return false;var attributeName=attributeNameElement.textContent;var attributeValueElement=attribute.getElementsByClassName("webkit-html-attribute-value")[0];function removeZeroWidthSpaceRecursive(node)
274 {if(node.nodeType===Node.TEXT_NODE){node.nodeValue=node.nodeValue.replace(/\u200B/g,"");return;}
275 if(node.nodeType!==Node.ELEMENT_NODE)
276 return;for(var child=node.firstChild;child;child=child.nextSibling)
277 removeZeroWidthSpaceRecursive(child);}
278 var domNode;var listItemElement=attribute.enclosingNodeOrSelfWithNodeName("li");if(attributeName&&attributeValueElement&&listItemElement&&listItemElement.treeElement)
279 domNode=listItemElement.treeElement.representedObject;var attributeValue=domNode?domNode.getAttribute(attributeName):undefined;if(typeof attributeValue!=="undefined")
280 attributeValueElement.textContent=attributeValue;removeZeroWidthSpaceRecursive(attribute);var config=new WebInspector.InplaceEditor.Config(this._attributeEditingCommitted.bind(this),this._editingCancelled.bind(this),attributeName);function handleKeyDownEvents(event)
281 {var isMetaOrCtrl=WebInspector.isMac()?event.metaKey&&!event.shiftKey&&!event.ctrlKey&&!event.altKey:event.ctrlKey&&!event.shiftKey&&!event.metaKey&&!event.altKey;if(isEnterKey(event)&&(event.isMetaOrCtrlForTest||!config.multiline||isMetaOrCtrl))
282 return"commit";else if(event.keyCode===WebInspector.KeyboardShortcut.Keys.Esc.code||event.keyIdentifier==="U+001B")
283 return"cancel";else if(event.keyIdentifier==="U+0009")
284 return"move-"+(event.shiftKey?"backward":"forward");else{WebInspector.handleElementValueModifications(event,attribute);return"";}}
285 config.customFinishHandler=handleKeyDownEvents;this._editing=WebInspector.InplaceEditor.startEditing(attribute,config);window.getSelection().setBaseAndExtent(elementForSelection,0,elementForSelection,1);return true;},_startEditingTextNode:function(textNodeElement)
286 {if(WebInspector.isBeingEdited(textNodeElement))
287 return true;var textNode=this._node;if(textNode.nodeType()===Node.ELEMENT_NODE&&textNode.firstChild)
288 textNode=textNode.firstChild;var container=textNodeElement.enclosingNodeOrSelfWithClass("webkit-html-text-node");if(container)
289 container.textContent=textNode.nodeValue();var config=new WebInspector.InplaceEditor.Config(this._textNodeEditingCommitted.bind(this,textNode),this._editingCancelled.bind(this));this._editing=WebInspector.InplaceEditor.startEditing(textNodeElement,config);window.getSelection().setBaseAndExtent(textNodeElement,0,textNodeElement,1);return true;},_startEditingTagName:function(tagNameElement)
290 {if(!tagNameElement){tagNameElement=this.listItemElement.getElementsByClassName("webkit-html-tag-name")[0];if(!tagNameElement)
291 return false;}
292 var tagName=tagNameElement.textContent;if(WebInspector.ElementsTreeElement.EditTagBlacklist[tagName.toLowerCase()])
293 return false;if(WebInspector.isBeingEdited(tagNameElement))
294 return true;var closingTagElement=this._distinctClosingTagElement();function keyupListener(event)
295 {if(closingTagElement)
296 closingTagElement.textContent="</"+tagNameElement.textContent+">";}
297 function editingComitted(element,newTagName)
298 {tagNameElement.removeEventListener('keyup',keyupListener,false);this._tagNameEditingCommitted.apply(this,arguments);}
299 function editingCancelled()
300 {tagNameElement.removeEventListener('keyup',keyupListener,false);this._editingCancelled.apply(this,arguments);}
301 tagNameElement.addEventListener('keyup',keyupListener,false);var config=new WebInspector.InplaceEditor.Config(editingComitted.bind(this),editingCancelled.bind(this),tagName);this._editing=WebInspector.InplaceEditor.startEditing(tagNameElement,config);window.getSelection().setBaseAndExtent(tagNameElement,0,tagNameElement,1);return true;},_startEditingAsHTML:function(commitCallback,error,initialValue)
302 {if(error)
303 return;if(this._editing)
304 return;function consume(event)
305 {if(event.eventPhase===Event.AT_TARGET)
306 event.consume(true);}
307 initialValue=this._convertWhitespaceToEntities(initialValue).text;this._htmlEditElement=document.createElement("div");this._htmlEditElement.className="source-code elements-tree-editor";var child=this.listItemElement.firstChild;while(child){child.style.display="none";child=child.nextSibling;}
308 if(this._childrenListNode)
309 this._childrenListNode.style.display="none";this.listItemElement.appendChild(this._htmlEditElement);this.treeOutline.childrenListElement.parentElement.addEventListener("mousedown",consume,false);this.updateSelection();function commit(element,newValue)
310 {commitCallback(initialValue,newValue);dispose.call(this);}
311 function dispose()
312 {delete this._editing;delete this.treeOutline._multilineEditing;this.listItemElement.removeChild(this._htmlEditElement);delete this._htmlEditElement;if(this._childrenListNode)
313 this._childrenListNode.style.removeProperty("display");var child=this.listItemElement.firstChild;while(child){child.style.removeProperty("display");child=child.nextSibling;}
314 this.treeOutline.childrenListElement.parentElement.removeEventListener("mousedown",consume,false);this.updateSelection();this.treeOutline.element.focus();}
315 var config=new WebInspector.InplaceEditor.Config(commit.bind(this),dispose.bind(this));config.setMultilineOptions(initialValue,{name:"xml",htmlMode:true},"web-inspector-html",WebInspector.settings.domWordWrap.get(),true);this._editing=WebInspector.InplaceEditor.startEditing(this._htmlEditElement,config);this._editing.setWidth(this.treeOutline._visibleWidth);this.treeOutline._multilineEditing=this._editing;},_attributeEditingCommitted:function(element,newText,oldText,attributeName,moveDirection)
316 {delete this._editing;var treeOutline=this.treeOutline;function moveToNextAttributeIfNeeded(error)
317 {if(error)
318 this._editingCancelled(element,attributeName);if(!moveDirection)
319 return;treeOutline._updateModifiedNodes();var attributes=this._node.attributes();for(var i=0;i<attributes.length;++i){if(attributes[i].name!==attributeName)
320 continue;if(moveDirection==="backward"){if(i===0)
321 this._startEditingTagName();else
322 this._triggerEditAttribute(attributes[i-1].name);}else{if(i===attributes.length-1)
323 this._addNewAttribute();else
324 this._triggerEditAttribute(attributes[i+1].name);}
325 return;}
326 if(moveDirection==="backward"){if(newText===" "){if(attributes.length>0)
327 this._triggerEditAttribute(attributes[attributes.length-1].name);}else{if(attributes.length>1)
328 this._triggerEditAttribute(attributes[attributes.length-2].name);}}else if(moveDirection==="forward"){if(!/^\s*$/.test(newText))
329 this._addNewAttribute();else
330 this._startEditingTagName();}}
331 if(!attributeName.trim()&&!newText.trim()){element.remove();moveToNextAttributeIfNeeded.call(this);return;}
332 if(oldText!==newText){this._node.setAttribute(attributeName,newText,moveToNextAttributeIfNeeded.bind(this));return;}
333 this.updateTitle();moveToNextAttributeIfNeeded.call(this);},_tagNameEditingCommitted:function(element,newText,oldText,tagName,moveDirection)
334 {delete this._editing;var self=this;function cancel()
335 {var closingTagElement=self._distinctClosingTagElement();if(closingTagElement)
336 closingTagElement.textContent="</"+tagName+">";self._editingCancelled(element,tagName);moveToNextAttributeIfNeeded.call(self);}
337 function moveToNextAttributeIfNeeded()
338 {if(moveDirection!=="forward"){this._addNewAttribute();return;}
339 var attributes=this._node.attributes();if(attributes.length>0)
340 this._triggerEditAttribute(attributes[0].name);else
341 this._addNewAttribute();}
342 newText=newText.trim();if(newText===oldText){cancel();return;}
343 var treeOutline=this.treeOutline;var wasExpanded=this.expanded;function changeTagNameCallback(error,nodeId)
344 {if(error||!nodeId){cancel();return;}
345 var newTreeItem=treeOutline._selectNodeAfterEdit(wasExpanded,error,nodeId);moveToNextAttributeIfNeeded.call(newTreeItem);}
346 this._node.setNodeName(newText,changeTagNameCallback);},_textNodeEditingCommitted:function(textNode,element,newText)
347 {delete this._editing;function callback()
348 {this.updateTitle();}
349 textNode.setNodeValue(newText,callback.bind(this));},_editingCancelled:function(element,context)
350 {delete this._editing;this.updateTitle();},_distinctClosingTagElement:function()
351 {if(this.expanded){var closers=this._childrenListNode.querySelectorAll(".close");return closers[closers.length-1];}
352 var tags=this.listItemElement.getElementsByClassName("webkit-html-tag");return(tags.length===1?null:tags[tags.length-1]);},updateTitle:function(onlySearchQueryChanged)
353 {if(this._editing)
354 return;if(onlySearchQueryChanged){if(this._highlightResult)
355 this._updateSearchHighlight(false);}else{var nodeInfo=this._nodeTitleInfo(WebInspector.linkifyURLAsNode);if(nodeInfo.shadowRoot)
356 this.listItemElement.classList.add("shadow-root");var highlightElement=document.createElement("span");highlightElement.className="highlight";highlightElement.appendChild(nodeInfo.titleDOM);this.title=highlightElement;this._updateDecorations();delete this._highlightResult;}
357 delete this.selectionElement;if(this.selected)
358 this.updateSelection();this._preventFollowingLinksOnDoubleClick();this._highlightSearchResults();},_createDecoratorElement:function()
359 {var node=this._node;var decoratorMessages=[];var parentDecoratorMessages=[];for(var i=0;i<this.treeOutline._nodeDecorators.length;++i){var decorator=this.treeOutline._nodeDecorators[i];var message=decorator.decorate(node);if(message){decoratorMessages.push(message);continue;}
360 if(this.expanded||this._elementCloseTag)
361 continue;message=decorator.decorateAncestor(node);if(message)
362 parentDecoratorMessages.push(message)}
363 if(!decoratorMessages.length&&!parentDecoratorMessages.length)
364 return null;var decoratorElement=document.createElement("div");decoratorElement.classList.add("elements-gutter-decoration");if(!decoratorMessages.length)
365 decoratorElement.classList.add("elements-has-decorated-children");decoratorElement.title=decoratorMessages.concat(parentDecoratorMessages).join("\n");return decoratorElement;},_updateDecorations:function()
366 {if(this._decoratorElement)
367 this._decoratorElement.remove();this._decoratorElement=this._createDecoratorElement();if(this._decoratorElement&&this.listItemElement)
368 this.listItemElement.insertBefore(this._decoratorElement,this.listItemElement.firstChild);},_buildAttributeDOM:function(parentElement,name,value,forceValue,node,linkify)
369 {var closingPunctuationRegex=/[\/;:\)\]\}]/g;var highlightIndex=0;var highlightCount;var additionalHighlightOffset=0;var result;function replacer(match,replaceOffset){while(highlightIndex<highlightCount&&result.entityRanges[highlightIndex].offset<replaceOffset){result.entityRanges[highlightIndex].offset+=additionalHighlightOffset;++highlightIndex;}
370 additionalHighlightOffset+=1;return match+"\u200B";}
371 function setValueWithEntities(element,value)
372 {var attrValueElement=element.createChild("span","webkit-html-attribute-value");result=this._convertWhitespaceToEntities(value);highlightCount=result.entityRanges.length;value=result.text.replace(closingPunctuationRegex,replacer);while(highlightIndex<highlightCount){result.entityRanges[highlightIndex].offset+=additionalHighlightOffset;++highlightIndex;}
373 attrValueElement.textContent=value;WebInspector.highlightRangesWithStyleClass(attrValueElement,result.entityRanges,"webkit-html-entity-value");}
374 var hasText=(forceValue||value.length>0);var attrSpanElement=parentElement.createChild("span","webkit-html-attribute");var attrNameElement=attrSpanElement.createChild("span","webkit-html-attribute-name");attrNameElement.textContent=name;if(hasText)
375 attrSpanElement.appendChild(document.createTextNode("=\u200B\""));if(linkify&&(name==="src"||name==="href")){var rewrittenHref=node.resolveURL(value);if(rewrittenHref===null){setValueWithEntities.call(this,attrSpanElement,value);}else{value=value.replace(closingPunctuationRegex,"$&\u200B");if(value.startsWith("data:"))
376 value=value.trimMiddle(60);attrSpanElement.appendChild(linkify(rewrittenHref,value,"webkit-html-attribute-value",node.nodeName().toLowerCase()==="a"));}}else{setValueWithEntities.call(this,attrSpanElement,value);}
377 if(hasText)
378 attrSpanElement.appendChild(document.createTextNode("\""));},_buildPseudoElementDOM:function(parentElement,pseudoElementName)
379 {var pseudoElement=parentElement.createChild("span","webkit-html-pseudo-element");pseudoElement.textContent="::"+pseudoElementName;parentElement.appendChild(document.createTextNode("\u200B"));},_buildTagDOM:function(parentElement,tagName,isClosingTag,isDistinctTreeElement,linkify)
380 {var node=this._node;var classes=["webkit-html-tag"];if(isClosingTag&&isDistinctTreeElement)
381 classes.push("close");var tagElement=parentElement.createChild("span",classes.join(" "));tagElement.appendChild(document.createTextNode("<"));var tagNameElement=tagElement.createChild("span",isClosingTag?"":"webkit-html-tag-name");tagNameElement.textContent=(isClosingTag?"/":"")+tagName;if(!isClosingTag&&node.hasAttributes()){var attributes=node.attributes();for(var i=0;i<attributes.length;++i){var attr=attributes[i];tagElement.appendChild(document.createTextNode(" "));this._buildAttributeDOM(tagElement,attr.name,attr.value,false,node,linkify);}}
382 tagElement.appendChild(document.createTextNode(">"));parentElement.appendChild(document.createTextNode("\u200B"));},_convertWhitespaceToEntities:function(text)
383 {var result="";var resultLength=0;var lastIndexAfterEntity=0;var entityRanges=[];var charToEntity=WebInspector.ElementsTreeOutline.MappedCharToEntity;for(var i=0,size=text.length;i<size;++i){var char=text.charAt(i);if(charToEntity[char]){result+=text.substring(lastIndexAfterEntity,i);var entityValue="&"+charToEntity[char]+";";entityRanges.push({offset:result.length,length:entityValue.length});result+=entityValue;lastIndexAfterEntity=i+1;}}
384 if(result)
385 result+=text.substring(lastIndexAfterEntity);return{text:result||text,entityRanges:entityRanges};},_nodeTitleInfo:function(linkify)
386 {var node=this._node;var info={titleDOM:document.createDocumentFragment(),hasChildren:this.hasChildren};switch(node.nodeType()){case Node.ATTRIBUTE_NODE:this._buildAttributeDOM(info.titleDOM,node.name,node.value,true);break;case Node.ELEMENT_NODE:if(node.pseudoType()){this._buildPseudoElementDOM(info.titleDOM,node.pseudoType());info.hasChildren=false;break;}
387 var tagName=node.nodeNameInCorrectCase();if(this._elementCloseTag){this._buildTagDOM(info.titleDOM,tagName,true,true);info.hasChildren=false;break;}
388 this._buildTagDOM(info.titleDOM,tagName,false,false,linkify);var showInlineText=this._showInlineText()&&!this.hasChildren;if(!this.expanded&&!showInlineText&&(this.treeOutline.isXMLMimeType||!WebInspector.ElementsTreeElement.ForbiddenClosingTagElements[tagName])){if(this.hasChildren){var textNodeElement=info.titleDOM.createChild("span","webkit-html-text-node bogus");textNodeElement.textContent="\u2026";info.titleDOM.appendChild(document.createTextNode("\u200B"));}
389 this._buildTagDOM(info.titleDOM,tagName,true,false);}
390 if(showInlineText){var textNodeElement=info.titleDOM.createChild("span","webkit-html-text-node");var result=this._convertWhitespaceToEntities(node.firstChild.nodeValue());textNodeElement.textContent=result.text;WebInspector.highlightRangesWithStyleClass(textNodeElement,result.entityRanges,"webkit-html-entity-value");info.titleDOM.appendChild(document.createTextNode("\u200B"));this._buildTagDOM(info.titleDOM,tagName,true,false);info.hasChildren=false;}
391 break;case Node.TEXT_NODE:if(node.parentNode&&node.parentNode.nodeName().toLowerCase()==="script"){var newNode=info.titleDOM.createChild("span","webkit-html-text-node webkit-html-js-node");newNode.textContent=node.nodeValue();var javascriptSyntaxHighlighter=new WebInspector.DOMSyntaxHighlighter("text/javascript",true);javascriptSyntaxHighlighter.syntaxHighlightNode(newNode);}else if(node.parentNode&&node.parentNode.nodeName().toLowerCase()==="style"){var newNode=info.titleDOM.createChild("span","webkit-html-text-node webkit-html-css-node");newNode.textContent=node.nodeValue();var cssSyntaxHighlighter=new WebInspector.DOMSyntaxHighlighter("text/css",true);cssSyntaxHighlighter.syntaxHighlightNode(newNode);}else{info.titleDOM.appendChild(document.createTextNode("\""));var textNodeElement=info.titleDOM.createChild("span","webkit-html-text-node");var result=this._convertWhitespaceToEntities(node.nodeValue());textNodeElement.textContent=result.text;WebInspector.highlightRangesWithStyleClass(textNodeElement,result.entityRanges,"webkit-html-entity-value");info.titleDOM.appendChild(document.createTextNode("\""));}
392 break;case Node.COMMENT_NODE:var commentElement=info.titleDOM.createChild("span","webkit-html-comment");commentElement.appendChild(document.createTextNode("<!--"+node.nodeValue()+"-->"));break;case Node.DOCUMENT_TYPE_NODE:var docTypeElement=info.titleDOM.createChild("span","webkit-html-doctype");docTypeElement.appendChild(document.createTextNode("<!DOCTYPE "+node.nodeName()));if(node.publicId){docTypeElement.appendChild(document.createTextNode(" PUBLIC \""+node.publicId+"\""));if(node.systemId)
393 docTypeElement.appendChild(document.createTextNode(" \""+node.systemId+"\""));}else if(node.systemId)
394 docTypeElement.appendChild(document.createTextNode(" SYSTEM \""+node.systemId+"\""));if(node.internalSubset)
395 docTypeElement.appendChild(document.createTextNode(" ["+node.internalSubset+"]"));docTypeElement.appendChild(document.createTextNode(">"));break;case Node.CDATA_SECTION_NODE:var cdataElement=info.titleDOM.createChild("span","webkit-html-text-node");cdataElement.appendChild(document.createTextNode("<![CDATA["+node.nodeValue()+"]]>"));break;case Node.DOCUMENT_FRAGMENT_NODE:var fragmentElement=info.titleDOM.createChild("span","webkit-html-fragment");if(node.isInShadowTree()){var shadowRootType=node.shadowRootType();if(shadowRootType){info.shadowRoot=true;fragmentElement.classList.add("shadow-root");}}
396 fragmentElement.textContent=node.nodeNameInCorrectCase().collapseWhitespace();break;default:info.titleDOM.appendChild(document.createTextNode(node.nodeNameInCorrectCase().collapseWhitespace()));}
397 return info;},_showInlineText:function()
398 {if(this._node.importedDocument()||this._node.templateContent()||this._visibleShadowRoots().length>0||this._node.hasPseudoElements())
399 return false;if(this._node.nodeType()!==Node.ELEMENT_NODE)
400 return false;if(!this._node.firstChild||this._node.firstChild!==this._node.lastChild||this._node.firstChild.nodeType()!==Node.TEXT_NODE)
401 return false;var textChild=this._node.firstChild;if(textChild.nodeValue().length<Preferences.maxInlineTextChildLength)
402 return true;return false;},remove:function()
403 {if(this._node.pseudoType())
404 return;var parentElement=this.parent;if(!parentElement)
405 return;var self=this;function removeNodeCallback(error,removedNodeId)
406 {if(error)
407 return;parentElement.removeChild(self);parentElement._adjustCollapsedRange();}
408 if(!this._node.parentNode||this._node.parentNode.nodeType()===Node.DOCUMENT_NODE)
409 return;this._node.removeNode(removeNodeCallback);},_editAsHTML:function()
410 {var node=this._node;if(node.pseudoType())
411 return;var treeOutline=this.treeOutline;var parentNode=node.parentNode;var index=node.index;var wasExpanded=this.expanded;function selectNode(error,nodeId)
412 {if(error)
413 return;treeOutline._updateModifiedNodes();var newNode=parentNode?parentNode.children()[index]||parentNode:null;if(!newNode)
414 return;treeOutline.selectDOMNode(newNode,true);if(wasExpanded){var newTreeItem=treeOutline.findTreeElement(newNode);if(newTreeItem)
415 newTreeItem.expand();}}
416 function commitChange(initialValue,value)
417 {if(initialValue!==value)
418 node.setOuterHTML(value,selectNode);else
419 return;}
420 node.getOuterHTML(this._startEditingAsHTML.bind(this,commitChange));},_copyHTML:function()
421 {this._node.copyNode();},_copyCSSPath:function()
422 {InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath(this._node,true));},_copyXPath:function()
423 {InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(this._node,true));},_highlightSearchResults:function()
424 {if(!this._searchQuery||!this._searchHighlightsVisible)
425 return;if(this._highlightResult){this._updateSearchHighlight(true);return;}
426 var text=this.listItemElement.textContent;var regexObject=createPlainTextSearchRegex(this._searchQuery,"gi");var offset=0;var match=regexObject.exec(text);var matchRanges=[];while(match){matchRanges.push(new WebInspector.SourceRange(match.index,match[0].length));match=regexObject.exec(text);}
427 if(!matchRanges.length)
428 matchRanges.push(new WebInspector.SourceRange(0,text.length));this._highlightResult=[];WebInspector.highlightSearchResults(this.listItemElement,matchRanges,this._highlightResult);},_scrollIntoView:function()
429 {function scrollIntoViewCallback(object)
430 {function scrollIntoView()
431 {this.scrollIntoViewIfNeeded(true);}
432 if(object)
433 object.callFunction(scrollIntoView);}
434 WebInspector.RemoteObject.resolveNode(this._node,"",scrollIntoViewCallback);},_visibleShadowRoots:function()
435 {var roots=this._node.shadowRoots();if(roots.length&&!WebInspector.settings.showUAShadowDOM.get()){roots=roots.filter(function(root){return root.shadowRootType()===WebInspector.DOMNode.ShadowRootTypes.Author;});}
436 return roots;},_visibleChildren:function()
437 {var visibleChildren=this._visibleShadowRoots();if(this._node.importedDocument())
438 visibleChildren.push(this._node.importedDocument());if(this._node.templateContent())
439 visibleChildren.push(this._node.templateContent());var pseudoElements=this._node.pseudoElements();if(pseudoElements[WebInspector.DOMNode.PseudoElementNames.Before])
440 visibleChildren.push(pseudoElements[WebInspector.DOMNode.PseudoElementNames.Before]);if(this._node.childNodeCount())
441 visibleChildren=visibleChildren.concat(this._node.children());if(pseudoElements[WebInspector.DOMNode.PseudoElementNames.After])
442 visibleChildren.push(pseudoElements[WebInspector.DOMNode.PseudoElementNames.After]);return visibleChildren;},_visibleChildCount:function()
443 {var childCount=this._node.childNodeCount()+this._visibleShadowRoots().length;if(this._node.importedDocument())
444 ++childCount;if(this._node.templateContent())
445 ++childCount;for(var pseudoType in this._node.pseudoElements())
446 ++childCount;return childCount;},_updateHasChildren:function()
447 {this.hasChildren=!this._elementCloseTag&&!this._showInlineText()&&this._visibleChildCount()>0;},__proto__:TreeElement.prototype}
448 WebInspector.ElementsTreeUpdater=function(treeOutline)
449 {WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.NodeInserted,this._nodeInserted,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.NodeRemoved,this._nodeRemoved,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified,this._attributesUpdated,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved,this._attributesUpdated,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.CharacterDataModified,this._characterDataModified,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.DocumentUpdated,this._documentUpdated,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.ChildNodeCountUpdated,this._childNodeCountUpdated,this);this._treeOutline=treeOutline;this._recentlyModifiedNodes=new Map();}
450 WebInspector.ElementsTreeUpdater.prototype={_nodeModified:function(node,isUpdated,parentNode)
451 {if(this._treeOutline._visible)
452 this._updateModifiedNodesSoon();var entry=this._recentlyModifiedNodes.get(node);if(!entry){entry=new WebInspector.ElementsTreeUpdater.UpdateEntry(isUpdated,parentNode);this._recentlyModifiedNodes.put(node,entry);return;}
453 entry.isUpdated|=isUpdated;if(parentNode)
454 entry.parent=parentNode;},_documentUpdated:function(event)
455 {var inspectedRootDocument=event.data;this._reset();if(!inspectedRootDocument)
456 return;this._treeOutline.rootDOMNode=inspectedRootDocument;},_attributesUpdated:function(event)
457 {this._nodeModified(event.data.node,true);},_characterDataModified:function(event)
458 {this._nodeModified(event.data,true);},_nodeInserted:function(event)
459 {this._nodeModified(event.data,false,event.data.parentNode);},_nodeRemoved:function(event)
460 {this._nodeModified(event.data.node,false,event.data.parent);},_childNodeCountUpdated:function(event)
461 {var treeElement=this._treeOutline.findTreeElement(event.data);if(treeElement){var oldHasChildren=treeElement.hasChildren;treeElement._updateHasChildren();if(treeElement.hasChildren!==oldHasChildren)
462 treeElement.updateTitle();}},_updateModifiedNodesSoon:function()
463 {if(this._updateModifiedNodesTimeout)
464 return;this._updateModifiedNodesTimeout=setTimeout(this._updateModifiedNodes.bind(this),50);},_updateModifiedNodes:function()
465 {if(this._updateModifiedNodesTimeout){clearTimeout(this._updateModifiedNodesTimeout);delete this._updateModifiedNodesTimeout;}
466 var updatedParentTreeElements=[];var hidePanelWhileUpdating=this._recentlyModifiedNodes.size()>10;if(hidePanelWhileUpdating){var treeOutlineContainerElement=this._treeOutline.element.parentNode;var originalScrollTop=treeOutlineContainerElement?treeOutlineContainerElement.scrollTop:0;this._treeOutline.element.classList.add("hidden");}
467 var nodes=this._recentlyModifiedNodes.keys();for(var i=0,size=nodes.length;i<size;++i){var node=nodes[i];var entry=this._recentlyModifiedNodes.get(node);var parent=entry.parent;if(parent===this._treeOutline._rootDOMNode){this._treeOutline.update();this._treeOutline.element.classList.remove("hidden");return;}
468 if(entry.isUpdated){var nodeItem=this._treeOutline.findTreeElement(node);if(nodeItem)
469 nodeItem.updateTitle();}
470 var parentNodeItem=parent?this._treeOutline.findTreeElement(parent):null;if(parentNodeItem&&!parentNodeItem.alreadyUpdatedChildren){parentNodeItem.updateChildren();parentNodeItem.alreadyUpdatedChildren=true;updatedParentTreeElements.push(parentNodeItem);}}
471 for(var i=0;i<updatedParentTreeElements.length;++i)
472 delete updatedParentTreeElements[i].alreadyUpdatedChildren;if(hidePanelWhileUpdating){this._treeOutline.element.classList.remove("hidden");if(originalScrollTop)
473 treeOutlineContainerElement.scrollTop=originalScrollTop;this._treeOutline.updateSelection();}
474 this._recentlyModifiedNodes.clear();this._treeOutline._fireElementsTreeUpdated(nodes);},_reset:function()
475 {this._treeOutline.rootDOMNode=null;this._treeOutline.selectDOMNode(null,false);WebInspector.domModel.hideDOMNodeHighlight();this._recentlyModifiedNodes.clear();}}
476 WebInspector.ElementsTreeUpdater.UpdateEntry=function(isUpdated,parent)
477 {this.isUpdated=isUpdated;if(parent)
478 this.parent=parent;}
479 WebInspector.ElementsTreeOutline.Renderer=function()
480 {}
481 WebInspector.ElementsTreeOutline.Renderer.prototype={render:function(object)
482 {if(!(object instanceof WebInspector.DOMNode))
483 return null;var treeOutline=new WebInspector.ElementsTreeOutline(false,false);treeOutline.rootDOMNode=(object);treeOutline.element.classList.add("outline-disclosure");if(!treeOutline.children[0].hasChildren)
484 treeOutline.element.classList.add("single-node");treeOutline.setVisible(true);treeOutline.element.treeElementForTest=treeOutline.children[0];return treeOutline.element;}};WebInspector.EventListenersSidebarPane=function()
485 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Event Listeners"));this.bodyElement.classList.add("events-pane");this.sections=[];var refreshButton=document.createElement("button");refreshButton.className="pane-title-button refresh";refreshButton.addEventListener("click",this._refreshButtonClicked.bind(this),false);refreshButton.title=WebInspector.UIString("Refresh");this.titleElement.appendChild(refreshButton);this.settingsSelectElement=document.createElement("select");this.settingsSelectElement.className="select-filter";var option=document.createElement("option");option.value="all";option.label=WebInspector.UIString("All Nodes");this.settingsSelectElement.appendChild(option);option=document.createElement("option");option.value="selected";option.label=WebInspector.UIString("Selected Node Only");this.settingsSelectElement.appendChild(option);var filter=WebInspector.settings.eventListenersFilter.get();if(filter==="all")
486 this.settingsSelectElement[0].selected=true;else if(filter==="selected")
487 this.settingsSelectElement[1].selected=true;this.settingsSelectElement.addEventListener("click",function(event){event.consume()},false);this.settingsSelectElement.addEventListener("change",this._changeSetting.bind(this),false);this.titleElement.appendChild(this.settingsSelectElement);this._linkifier=new WebInspector.Linkifier();}
488 WebInspector.EventListenersSidebarPane._objectGroupName="event-listeners-sidebar-pane";WebInspector.EventListenersSidebarPane.prototype={update:function(node)
489 {RuntimeAgent.releaseObjectGroup(WebInspector.EventListenersSidebarPane._objectGroupName);this._linkifier.reset();var body=this.bodyElement;body.removeChildren();this.sections=[];var self=this;function callback(error,eventListeners){if(error)
490 return;var selectedNodeOnly="selected"===WebInspector.settings.eventListenersFilter.get();var sectionNames=[];var sectionMap={};for(var i=0;i<eventListeners.length;++i){var eventListener=eventListeners[i];if(selectedNodeOnly&&(node.id!==eventListener.nodeId))
491 continue;eventListener.node=WebInspector.domModel.nodeForId(eventListener.nodeId);delete eventListener.nodeId;if(/^function _inspectorCommandLineAPI_logEvent\(/.test(eventListener.handlerBody.toString()))
492 continue;var type=eventListener.type;var section=sectionMap[type];if(!section){section=new WebInspector.EventListenersSection(type,node.id,self._linkifier);sectionMap[type]=section;sectionNames.push(type);self.sections.push(section);}
493 section.addListener(eventListener);}
494 if(sectionNames.length===0){var div=document.createElement("div");div.className="info";div.textContent=WebInspector.UIString("No Event Listeners");body.appendChild(div);return;}
495 sectionNames.sort();for(var i=0;i<sectionNames.length;++i){var section=sectionMap[sectionNames[i]];body.appendChild(section.element);}}
496 if(node)
497 node.eventListeners(WebInspector.EventListenersSidebarPane._objectGroupName,callback);this._selectedNode=node;},willHide:function()
498 {delete this._selectedNode;},_refreshButtonClicked:function()
499 {if(!this._selectedNode)
500 return;this.update(this._selectedNode);},_changeSetting:function()
501 {var selectedOption=this.settingsSelectElement[this.settingsSelectElement.selectedIndex];WebInspector.settings.eventListenersFilter.set(selectedOption.value);this.update(this._selectedNode);},__proto__:WebInspector.SidebarPane.prototype}
502 WebInspector.EventListenersSection=function(title,nodeId,linkifier)
503 {this.eventListeners=[];this._nodeId=nodeId;this._linkifier=linkifier;WebInspector.PropertiesSection.call(this,title);this.propertiesElement.remove();delete this.propertiesElement;delete this.propertiesTreeOutline;this._eventBars=document.createElement("div");this._eventBars.className="event-bars";this.element.appendChild(this._eventBars);}
504 WebInspector.EventListenersSection.prototype={addListener:function(eventListener)
505 {var eventListenerBar=new WebInspector.EventListenerBar(eventListener,this._nodeId,this._linkifier);this._eventBars.appendChild(eventListenerBar.element);},__proto__:WebInspector.PropertiesSection.prototype}
506 WebInspector.EventListenerBar=function(eventListener,nodeId,linkifier)
507 {WebInspector.ObjectPropertiesSection.call(this,WebInspector.RemoteObject.fromPrimitiveValue(""));this.eventListener=eventListener;this._nodeId=nodeId;this._setNodeTitle();this._setFunctionSubtitle(linkifier);this.editable=false;this.element.className="event-bar";this.headerElement.classList.add("source-code");this.propertiesElement.className="event-properties properties-tree source-code";}
508 WebInspector.EventListenerBar.prototype={update:function()
509 {function updateWithNodeObject(nodeObject)
510 {var properties=[];properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("type",this.eventListener.type));properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("useCapture",this.eventListener.useCapture));properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("isAttribute",this.eventListener.isAttribute));if(nodeObject)
511 properties.push(new WebInspector.RemoteObjectProperty("node",nodeObject));if(typeof this.eventListener.handler!=="undefined"){var remoteObject=WebInspector.RemoteObject.fromPayload(this.eventListener.handler);properties.push(new WebInspector.RemoteObjectProperty("handler",remoteObject));}
512 properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("listenerBody",this.eventListener.handlerBody));if(this.eventListener.sourceName)
513 properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("sourceName",this.eventListener.sourceName));properties.push(WebInspector.RemoteObjectProperty.fromPrimitiveValue("lineNumber",this.eventListener.location.lineNumber+1));this.updateProperties(properties);}
514 WebInspector.RemoteObject.resolveNode(this.eventListener.node,WebInspector.EventListenersSidebarPane._objectGroupName,updateWithNodeObject.bind(this));},_setNodeTitle:function()
515 {var node=this.eventListener.node;if(!node)
516 return;if(node.nodeType()===Node.DOCUMENT_NODE){this.titleElement.textContent="document";return;}
517 if(node.id===this._nodeId){this.titleElement.textContent=WebInspector.DOMPresentationUtils.simpleSelector(node);return;}
518 this.titleElement.removeChildren();this.titleElement.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(this.eventListener.node));},_setFunctionSubtitle:function(linkifier)
519 {this.subtitleElement.removeChildren();var urlElement=linkifier.linkifyRawLocation(this.eventListener.location);if(!urlElement){var url=this.eventListener.sourceName;var lineNumber=this.eventListener.location.lineNumber;var columnNumber=0;urlElement=linkifier.linkifyLocation(url,lineNumber,columnNumber);}
520 this.subtitleElement.appendChild(urlElement);},__proto__:WebInspector.ObjectPropertiesSection.prototype};WebInspector.MetricsSidebarPane=function()
521 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Metrics"));WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged,this._styleSheetOrMediaQueryResultChanged,this);WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.MediaQueryResultChanged,this._styleSheetOrMediaQueryResultChanged,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified,this._attributesUpdated,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved,this._attributesUpdated,this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameResized,this._frameResized,this);}
522 WebInspector.MetricsSidebarPane.prototype={update:function(node)
523 {if(node)
524 this.node=node;this._innerUpdate();},_innerUpdate:function()
525 {if(this._isEditingMetrics)
526 return;var node=this.node;if(!node||node.nodeType()!==Node.ELEMENT_NODE){this.bodyElement.removeChildren();return;}
527 function callback(style)
528 {if(!style||this.node!==node)
529 return;this._updateMetrics(style);}
530 WebInspector.cssModel.getComputedStyleAsync(node.id,callback.bind(this));function inlineStyleCallback(style)
531 {if(!style||this.node!==node)
532 return;this.inlineStyle=style;}
533 WebInspector.cssModel.getInlineStylesAsync(node.id,inlineStyleCallback.bind(this));},_styleSheetOrMediaQueryResultChanged:function()
534 {this._innerUpdate();},_frameResized:function()
535 {function refreshContents()
536 {this._innerUpdate();delete this._activeTimer;}
537 if(this._activeTimer)
538 clearTimeout(this._activeTimer);this._activeTimer=setTimeout(refreshContents.bind(this),100);},_attributesUpdated:function(event)
539 {if(this.node!==event.data.node)
540 return;this._innerUpdate();},_getPropertyValueAsPx:function(style,propertyName)
541 {return Number(style.getPropertyValue(propertyName).replace(/px$/,"")||0);},_getBox:function(computedStyle,componentName)
542 {var suffix=componentName==="border"?"-width":"";var left=this._getPropertyValueAsPx(computedStyle,componentName+"-left"+suffix);var top=this._getPropertyValueAsPx(computedStyle,componentName+"-top"+suffix);var right=this._getPropertyValueAsPx(computedStyle,componentName+"-right"+suffix);var bottom=this._getPropertyValueAsPx(computedStyle,componentName+"-bottom"+suffix);return{left:left,top:top,right:right,bottom:bottom};},_highlightDOMNode:function(showHighlight,mode,event)
543 {event.consume();var nodeId=showHighlight&&this.node?this.node.id:0;if(nodeId){if(this._highlightMode===mode)
544 return;this._highlightMode=mode;WebInspector.domModel.highlightDOMNode(nodeId,mode);}else{delete this._highlightMode;WebInspector.domModel.hideDOMNodeHighlight();}
545 for(var i=0;this._boxElements&&i<this._boxElements.length;++i){var element=this._boxElements[i];if(!nodeId||mode==="all"||element._name===mode)
546 element.style.backgroundColor=element._backgroundColor;else
547 element.style.backgroundColor="";}},_updateMetrics:function(style)
548 {var metricsElement=document.createElement("div");metricsElement.className="metrics";var self=this;function createBoxPartElement(style,name,side,suffix)
549 {var propertyName=(name!=="position"?name+"-":"")+side+suffix;var value=style.getPropertyValue(propertyName);if(value===""||(name!=="position"&&value==="0px"))
550 value="\u2012";else if(name==="position"&&value==="auto")
551 value="\u2012";value=value.replace(/px$/,"");value=Number.toFixedIfFloating(value);var element=document.createElement("div");element.className=side;element.textContent=value;element.addEventListener("dblclick",this.startEditing.bind(this,element,name,propertyName,style),false);return element;}
552 function getContentAreaWidthPx(style)
553 {var width=style.getPropertyValue("width").replace(/px$/,"");if(!isNaN(width)&&style.getPropertyValue("box-sizing")==="border-box"){var borderBox=self._getBox(style,"border");var paddingBox=self._getBox(style,"padding");width=width-borderBox.left-borderBox.right-paddingBox.left-paddingBox.right;}
554 return Number.toFixedIfFloating(width);}
555 function getContentAreaHeightPx(style)
556 {var height=style.getPropertyValue("height").replace(/px$/,"");if(!isNaN(height)&&style.getPropertyValue("box-sizing")==="border-box"){var borderBox=self._getBox(style,"border");var paddingBox=self._getBox(style,"padding");height=height-borderBox.top-borderBox.bottom-paddingBox.top-paddingBox.bottom;}
557 return Number.toFixedIfFloating(height);}
558 var noMarginDisplayType={"table-cell":true,"table-column":true,"table-column-group":true,"table-footer-group":true,"table-header-group":true,"table-row":true,"table-row-group":true};var noPaddingDisplayType={"table-column":true,"table-column-group":true,"table-footer-group":true,"table-header-group":true,"table-row":true,"table-row-group":true};var noPositionType={"static":true};var boxes=["content","padding","border","margin","position"];var boxColors=[WebInspector.Color.PageHighlight.Content,WebInspector.Color.PageHighlight.Padding,WebInspector.Color.PageHighlight.Border,WebInspector.Color.PageHighlight.Margin,WebInspector.Color.fromRGBA([0,0,0,0])];var boxLabels=[WebInspector.UIString("content"),WebInspector.UIString("padding"),WebInspector.UIString("border"),WebInspector.UIString("margin"),WebInspector.UIString("position")];var previousBox=null;this._boxElements=[];for(var i=0;i<boxes.length;++i){var name=boxes[i];if(name==="margin"&&noMarginDisplayType[style.getPropertyValue("display")])
559 continue;if(name==="padding"&&noPaddingDisplayType[style.getPropertyValue("display")])
560 continue;if(name==="position"&&noPositionType[style.getPropertyValue("position")])
561 continue;var boxElement=document.createElement("div");boxElement.className=name;boxElement._backgroundColor=boxColors[i].toString(WebInspector.Color.Format.RGBA);boxElement._name=name;boxElement.style.backgroundColor=boxElement._backgroundColor;boxElement.addEventListener("mouseover",this._highlightDOMNode.bind(this,true,name==="position"?"all":name),false);this._boxElements.push(boxElement);if(name==="content"){var widthElement=document.createElement("span");widthElement.textContent=getContentAreaWidthPx(style);widthElement.addEventListener("dblclick",this.startEditing.bind(this,widthElement,"width","width",style),false);var heightElement=document.createElement("span");heightElement.textContent=getContentAreaHeightPx(style);heightElement.addEventListener("dblclick",this.startEditing.bind(this,heightElement,"height","height",style),false);boxElement.appendChild(widthElement);boxElement.appendChild(document.createTextNode(" \u00D7 "));boxElement.appendChild(heightElement);}else{var suffix=(name==="border"?"-width":"");var labelElement=document.createElement("div");labelElement.className="label";labelElement.textContent=boxLabels[i];boxElement.appendChild(labelElement);boxElement.appendChild(createBoxPartElement.call(this,style,name,"top",suffix));boxElement.appendChild(document.createElement("br"));boxElement.appendChild(createBoxPartElement.call(this,style,name,"left",suffix));if(previousBox)
562 boxElement.appendChild(previousBox);boxElement.appendChild(createBoxPartElement.call(this,style,name,"right",suffix));boxElement.appendChild(document.createElement("br"));boxElement.appendChild(createBoxPartElement.call(this,style,name,"bottom",suffix));}
563 previousBox=boxElement;}
564 metricsElement.appendChild(previousBox);metricsElement.addEventListener("mouseover",this._highlightDOMNode.bind(this,false,""),false);this.bodyElement.removeChildren();this.bodyElement.appendChild(metricsElement);},startEditing:function(targetElement,box,styleProperty,computedStyle)
565 {if(WebInspector.isBeingEdited(targetElement))
566 return;var context={box:box,styleProperty:styleProperty,computedStyle:computedStyle};var boundKeyDown=this._handleKeyDown.bind(this,context,styleProperty);context.keyDownHandler=boundKeyDown;targetElement.addEventListener("keydown",boundKeyDown,false);this._isEditingMetrics=true;var config=new WebInspector.InplaceEditor.Config(this.editingCommitted.bind(this),this.editingCancelled.bind(this),context);WebInspector.InplaceEditor.startEditing(targetElement,config);window.getSelection().setBaseAndExtent(targetElement,0,targetElement,1);},_handleKeyDown:function(context,styleProperty,event)
567 {var element=event.currentTarget;function finishHandler(originalValue,replacementString)
568 {this._applyUserInput(element,replacementString,originalValue,context,false);}
569 function customNumberHandler(number)
570 {if(styleProperty!=="margin"&&number<0)
571 number=0;return number;}
572 WebInspector.handleElementValueModifications(event,element,finishHandler.bind(this),undefined,customNumberHandler);},editingEnded:function(element,context)
573 {delete this.originalPropertyData;delete this.previousPropertyDataCandidate;element.removeEventListener("keydown",context.keyDownHandler,false);delete this._isEditingMetrics;},editingCancelled:function(element,context)
574 {if("originalPropertyData"in this&&this.inlineStyle){if(!this.originalPropertyData){var pastLastSourcePropertyIndex=this.inlineStyle.pastLastSourcePropertyIndex();if(pastLastSourcePropertyIndex)
575 this.inlineStyle.allProperties[pastLastSourcePropertyIndex-1].setText("",false);}else
576 this.inlineStyle.allProperties[this.originalPropertyData.index].setText(this.originalPropertyData.propertyText,false);}
577 this.editingEnded(element,context);this.update();},_applyUserInput:function(element,userInput,previousContent,context,commitEditor)
578 {if(!this.inlineStyle){return this.editingCancelled(element,context);}
579 if(commitEditor&&userInput===previousContent)
580 return this.editingCancelled(element,context);if(context.box!=="position"&&(!userInput||userInput==="\u2012"))
581 userInput="0px";else if(context.box==="position"&&(!userInput||userInput==="\u2012"))
582 userInput="auto";userInput=userInput.toLowerCase();if(/^\d+$/.test(userInput))
583 userInput+="px";var styleProperty=context.styleProperty;var computedStyle=context.computedStyle;if(computedStyle.getPropertyValue("box-sizing")==="border-box"&&(styleProperty==="width"||styleProperty==="height")){if(!userInput.match(/px$/)){WebInspector.console.log("For elements with box-sizing: border-box, only absolute content area dimensions can be applied",WebInspector.ConsoleMessage.MessageLevel.Error,true);return;}
584 var borderBox=this._getBox(computedStyle,"border");var paddingBox=this._getBox(computedStyle,"padding");var userValuePx=Number(userInput.replace(/px$/,""));if(isNaN(userValuePx))
585 return;if(styleProperty==="width")
586 userValuePx+=borderBox.left+borderBox.right+paddingBox.left+paddingBox.right;else
587 userValuePx+=borderBox.top+borderBox.bottom+paddingBox.top+paddingBox.bottom;userInput=userValuePx+"px";}
588 this.previousPropertyDataCandidate=null;var self=this;var callback=function(style){if(!style)
589 return;self.inlineStyle=style;if(!("originalPropertyData"in self))
590 self.originalPropertyData=self.previousPropertyDataCandidate;if(typeof self._highlightMode!=="undefined"){WebInspector.domModel.highlightDOMNode(self.node.id,self._highlightMode);}
591 if(commitEditor){self.dispatchEventToListeners("metrics edited");self.update();}};var allProperties=this.inlineStyle.allProperties;for(var i=0;i<allProperties.length;++i){var property=allProperties[i];if(property.name!==context.styleProperty||property.inactive)
592 continue;this.previousPropertyDataCandidate=property;property.setValue(userInput,commitEditor,true,callback);return;}
593 this.inlineStyle.appendProperty(context.styleProperty,userInput,callback);},editingCommitted:function(element,userInput,previousContent,context)
594 {this.editingEnded(element,context);this._applyUserInput(element,userInput,previousContent,context,true);},__proto__:WebInspector.SidebarPane.prototype};WebInspector.OverridesView=function()
595 {WebInspector.VBox.call(this);this.registerRequiredCSS("overrides.css");this.registerRequiredCSS("helpScreen.css");this.element.classList.add("overrides-view");this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.shrinkableTabs=false;this._tabbedPane.verticalTabLayout=true;new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane);new WebInspector.OverridesView.ViewportTab().appendAsTab(this._tabbedPane);new WebInspector.OverridesView.UserAgentTab().appendAsTab(this._tabbedPane);new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane);this._lastSelectedTabSetting=WebInspector.settings.createSetting("lastSelectedEmulateTab","device");this._tabbedPane.selectTab(this._lastSelectedTabSetting.get());this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected,this._tabSelected,this);this._tabbedPane.show(this.element);this._warningFooter=this.element.createChild("div","overrides-footer");this._overridesWarningUpdated();WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.OverridesWarningUpdated,this._overridesWarningUpdated,this);}
596 WebInspector.OverridesView.prototype={_tabSelected:function(event)
597 {this._lastSelectedTabSetting.set(this._tabbedPane.selectedTabId);},_overridesWarningUpdated:function()
598 {var message=WebInspector.overridesSupport.warningMessage();this._warningFooter.classList.toggle("hidden",!message);this._warningFooter.textContent=message;},__proto__:WebInspector.VBox.prototype}
599 WebInspector.OverridesView.Tab=function(id,name,settings)
600 {WebInspector.VBox.call(this);this._id=id;this._name=name;this._settings=settings;for(var i=0;i<settings.length;++i)
601 settings[i].addChangeListener(this._updateActiveState,this);}
602 WebInspector.OverridesView.Tab.prototype={appendAsTab:function(tabbedPane)
603 {this._tabbedPane=tabbedPane;tabbedPane.appendTab(this._id,this._name,this);this._updateActiveState();},_updateActiveState:function()
604 {var active=false;for(var i=0;!active&&i<this._settings.length;++i)
605 active=this._settings[i].get();this._tabbedPane.element.classList.toggle("overrides-activate-"+this._id,active);this._tabbedPane.changeTabTitle(this._id,active?this._name+" \u2713":this._name);},_createInput:function(parentElement,id,defaultText,eventListener,numeric)
606 {var element=parentElement.createChild("input");element.id=id;element.type="text";element.maxLength=12;element.style.width="80px";element.value=defaultText;element.align="right";if(numeric)
607 element.className="numeric";element.addEventListener("input",eventListener,false);element.addEventListener("keydown",keyDownListener,false);function keyDownListener(event)
608 {if(isEnterKey(event))
609 eventListener(event);}
610 return element;},_createNonPersistedCheckbox:function(title,callback)
611 {var labelElement=document.createElement("label");var checkboxElement=labelElement.createChild("input");checkboxElement.type="checkbox";checkboxElement.checked=false;checkboxElement.addEventListener("click",onclick,false);labelElement.appendChild(document.createTextNode(title));return labelElement;function onclick()
612 {callback(checkboxElement.checked);}},_createSettingCheckbox:function(name,setting,callback)
613 {var checkbox=WebInspector.SettingsUI.createCheckbox(name,setting.get.bind(setting),listener,true);function listener(value)
614 {if(setting.get()===value)
615 return;setting.set(value);if(callback)
616 callback(value);}
617 setting.addChangeListener(changeListener);function changeListener()
618 {if(checkbox.firstChild.checked!==setting.get())
619 checkbox.firstChild.checked=setting.get();}
620 return checkbox;},__proto__:WebInspector.VBox.prototype}
621 WebInspector.OverridesView.DeviceTab=function()
622 {WebInspector.OverridesView.Tab.call(this,"device",WebInspector.UIString("Device"),[]);this.element.classList.add("overrides-device");this._emulatedDeviceSetting=WebInspector.settings.createSetting("emulatedDevice","Google Nexus 4");this._emulateDeviceViewportSetting=WebInspector.settings.overrideDeviceMetrics;this._emulateDeviceUserAgentSetting=WebInspector.settings.overrideUserAgent;this._deviceSelectElement=this.element.createChild("select");var devices=WebInspector.OverridesView.DeviceTab._phones.concat(WebInspector.OverridesView.DeviceTab._tablets);devices.sort();var selectionRestored=false;for(var i=0;i<devices.length;++i){var device=devices[i];var option=new Option(device[0],device[0]);option._userAgent=device[1];option._metrics=device[2];this._deviceSelectElement.add(option);if(this._emulatedDeviceSetting.get()===device[0]){this._deviceSelectElement.selectedIndex=i;selectionRestored=true;}}
623 if(!selectionRestored)
624 this._deviceSelectElement.selectedIndex=devices.length-1;this._deviceSelectElement.addEventListener("change",this._deviceSelected.bind(this),false);this._deviceSelectElement.addEventListener("keypress",this._keyPressed.bind(this),false);this._deviceSelectElement.disabled=WebInspector.OverridesSupport.isInspectingDevice();var buttonsBar=this.element.createChild("div");var emulateButton=buttonsBar.createChild("button","settings-tab-text-button");emulateButton.textContent=WebInspector.UIString("Emulate");emulateButton.addEventListener("click",this._emulateButtonClicked.bind(this),false);emulateButton.disabled=WebInspector.OverridesSupport.isInspectingDevice();var resetButton=buttonsBar.createChild("button","settings-tab-text-button");resetButton.textContent=WebInspector.UIString("Reset");resetButton.addEventListener("click",this._resetButtonClicked.bind(this),false);this._resetButton=resetButton;this._viewportValueLabel=this.element.createChild("div","overrides-device-value-label");this._viewportValueLabel.textContent=WebInspector.UIString("Viewport:");this._viewportValueElement=this._viewportValueLabel.createChild("span","overrides-device-value");this._userAgentLabel=this.element.createChild("div","overrides-device-value-label");this._userAgentLabel.textContent=WebInspector.UIString("User agent:");this._userAgentValueElement=this._userAgentLabel.createChild("span","overrides-device-value");this._updateValueLabels();WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.HasActiveOverridesChanged,this._hasActiveOverridesChanged,this);this._hasActiveOverridesChanged();}
625 WebInspector.OverridesView.DeviceTab._phones=[["Apple iPhone 3GS","Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5","320x480x1"],["Apple iPhone 4","Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5","640x960x2"],["Apple iPhone 5","Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53","640x1136x2"],["BlackBerry Z10","Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+","768x1280x2"],["BlackBerry Z30","Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+","720x1280x2"],["Google Nexus 4","Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19","768x1280x2"],["Google Nexus 5","Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19","1080x1920x3"],["Google Nexus S","Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Nexus S Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","480x800x1.5"],["HTC Evo, Touch HD, Desire HD, Desire","Mozilla/5.0 (Linux; U; Android 2.2; en-us; Sprint APA9292KT Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","480x800x1.5"],["HTC One X, EVO LTE","Mozilla/5.0 (Linux; Android 4.0.3; HTC One X Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19","720x1280x2"],["HTC Sensation, Evo 3D","Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","540x960x1.5"],["LG Optimus 2X, Optimus 3D, Optimus Black","Mozilla/5.0 (Linux; U; Android 2.2; en-us; LG-P990/V08c Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MMS/LG-Android-MMS-V1.0/1.2","480x800x1.5"],["LG Optimus G","Mozilla/5.0 (Linux; Android 4.0; LG-E975 Build/IMM76L) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19","768x1280x2"],["LG Optimus LTE, Optimus 4X HD","Mozilla/5.0 (Linux; U; Android 2.3; en-us; LG-P930 Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","720x1280x1.7"],["LG Optimus One","Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; LG-MS690 Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","320x480x1.5"],["Motorola Defy, Droid, Droid X, Milestone","Mozilla/5.0 (Linux; U; Android 2.0; en-us; Milestone Build/ SHOLS_U2_01.03.1) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17","480x854x1.5"],["Motorola Droid 3, Droid 4, Droid Razr, Atrix 4G, Atrix 2","Mozilla/5.0 (Linux; U; Android 2.2; en-us; Droid Build/FRG22D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","540x960x1"],["Motorola Droid Razr HD","Mozilla/5.0 (Linux; U; Android 2.3; en-us; DROID RAZR 4G Build/6.5.1-73_DHD-11_M1-29) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","720x1280x1"],["Nokia C5, C6, C7, N97, N8, X7","NokiaN97/21.1.107 (SymbianOS/9.4; Series60/5.0 Mozilla/5.0; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebkit/525 (KHTML, like Gecko) BrowserNG/7.1.4","360x640x1"],["Nokia Lumia 7X0, Lumia 8XX, Lumia 900, N800, N810, N900","Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 820)","480x800x1.5"],["Samsung Galaxy Note 3","Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","1080x1920x2"],["Samsung Galaxy Note II","Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","720x1280x2"],["Samsung Galaxy Note","Mozilla/5.0 (Linux; U; Android 2.3; en-us; SAMSUNG-SGH-I717 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","800x1280x2"],["Samsung Galaxy S III, Galaxy Nexus","Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","720x1280x2"],["Samsung Galaxy S, S II, W","Mozilla/5.0 (Linux; U; Android 2.1; en-us; GT-I9000 Build/ECLAIR) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2","480x800x1.5"],["Samsung Galaxy S4","Mozilla/5.0 (Linux; Android 4.2.2; GT-I9505 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36","1080x1920x3"],["Sony Xperia S, Ion","Mozilla/5.0 (Linux; U; Android 4.0; en-us; LT28at Build/6.1.C.1.111) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","720x1280x2"],["Sony Xperia Sola, U","Mozilla/5.0 (Linux; U; Android 2.3; en-us; SonyEricssonST25i Build/6.0.B.1.564) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","480x854x1"],["Sony Xperia Z, Z1","Mozilla/5.0 (Linux; U; Android 4.2; en-us; SonyC6903 Build/14.1.G.1.518) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","1080x1920x3"],];WebInspector.OverridesView.DeviceTab._tablets=[["Amazon Amazon Kindle Fire HD 7\u2033","Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire HD Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","1280x800x1.5"],["Amazon Amazon Kindle Fire HD 8.9\u2033","Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire HD Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","1920x1200x1.5"],["Amazon Amazon Kindle Fire","Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","1024x600x1"],["Apple iPad 1 / 2 / iPad Mini","Mozilla/5.0 (iPad; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5","1024x768x1"],["Apple iPad 3 / 4","Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53","2048x1536x2"],["BlackBerry PlayBook","Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+","1024x600x1"],["Google Nexus 10","Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36","2560x1600x2"],["Google Nexus 7 2","Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36","1920x1200x2"],["Google Nexus 7","Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36","1280x800x1.325"],["Motorola Xoom, Xyboard","Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/525.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2","1280x800x1"],["Samsung Galaxy Tab 7.7, 8.9, 10.1","Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","1280x800x1"],["Samsung Galaxy Tab","Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","1024x600x1"],];WebInspector.OverridesView.DeviceTab.prototype={_keyPressed:function(e)
626 {if(e.keyCode===WebInspector.KeyboardShortcut.Keys.Enter.code)
627 this._emulateButtonClicked();},_emulateButtonClicked:function()
628 {var option=this._deviceSelectElement.options[this._deviceSelectElement.selectedIndex];WebInspector.overridesSupport.emulateDevice(option._metrics,option._userAgent);},_resetButtonClicked:function()
629 {WebInspector.overridesSupport.reset();},_hasActiveOverridesChanged:function()
630 {this._resetButton.disabled=!WebInspector.overridesSupport.hasActiveOverrides();},_deviceSelected:function()
631 {var option=this._deviceSelectElement.options[this._deviceSelectElement.selectedIndex];this._emulatedDeviceSetting.set(option.value);this._updateValueLabels();},_updateValueLabels:function()
632 {var option=this._deviceSelectElement.options[this._deviceSelectElement.selectedIndex];var metrics;if(option._metrics&&(metrics=WebInspector.OverridesSupport.DeviceMetrics.parseSetting(option._metrics)))
633 this._viewportValueElement.textContent=WebInspector.UIString("%s \xD7 %s, devicePixelRatio = %s",metrics.width,metrics.height,metrics.deviceScaleFactor);else
634 this._viewportValueElement.textContent="";this._userAgentValueElement.textContent=option._userAgent||"";},__proto__:WebInspector.OverridesView.Tab.prototype}
635 WebInspector.OverridesView.ViewportTab=function()
636 {WebInspector.OverridesView.Tab.call(this,"viewport",WebInspector.UIString("Screen"),[WebInspector.settings.overrideDeviceMetrics,WebInspector.settings.overrideCSSMedia]);this.element.classList.add("overrides-viewport");const metricsSetting=WebInspector.settings.deviceMetrics.get();var metrics=WebInspector.OverridesSupport.DeviceMetrics.parseSetting(metricsSetting);var checkbox=this._createSettingCheckbox(WebInspector.UIString("Emulate screen"),WebInspector.settings.overrideDeviceMetrics,this._onMetricsCheckboxClicked.bind(this));checkbox.firstChild.disabled=WebInspector.OverridesSupport.isInspectingDevice();WebInspector.settings.deviceMetrics.addChangeListener(this._updateDeviceMetricsElement,this);this.element.appendChild(checkbox);this.element.appendChild(this._createDeviceMetricsElement(metrics));this.element.appendChild(this._createMediaEmulationFragment());var footnote=this.element.createChild("p","help-footnote");var footnoteLink=footnote.createChild("a");footnoteLink.href="https://developers.google.com/chrome-developer-tools/docs/mobile-emulation";footnoteLink.target="_blank";footnoteLink.createTextChild(WebInspector.UIString("More information about screen emulation"));this._onMetricsCheckboxClicked(WebInspector.settings.overrideDeviceMetrics.get());}
637 WebInspector.OverridesView.ViewportTab.prototype={_onMetricsCheckboxClicked:function(enabled)
638 {if(enabled&&!this._widthOverrideElement.value)
639 this._widthOverrideElement.focus();this._applyDeviceMetricsUserInput();},_applyDeviceMetricsUserInput:function()
640 {this._muteRangeListener=true;this._widthRangeInput.value=this._widthOverrideElement.value;delete this._muteRangeListener;if(this._applyDeviceMetricsTimer)
641 clearTimeout(this._applyDeviceMetricsTimer);this._applyDeviceMetricsTimer=setTimeout(this._doApplyDeviceMetricsUserInput.bind(this),50);},_doApplyDeviceMetricsUserInput:function()
642 {delete this._applyDeviceMetricsTimer;this._setDeviceMetricsOverride(WebInspector.OverridesSupport.DeviceMetrics.parseUserInput(this._widthOverrideElement.value.trim(),this._heightOverrideElement.value.trim(),this._deviceScaleFactorOverrideElement.value.trim(),this._textAutosizingOverrideCheckbox.checked),true);},_setDeviceMetricsOverride:function(metrics,userInputModified)
643 {function setValid(condition,element)
644 {if(condition)
645 element.classList.remove("error-input");else
646 element.classList.add("error-input");}
647 setValid(metrics&&metrics.isWidthValid(),this._widthOverrideElement);setValid(metrics&&metrics.isHeightValid(),this._heightOverrideElement);setValid(metrics&&metrics.isDeviceScaleFactorValid(),this._deviceScaleFactorOverrideElement);if(!metrics)
648 return;if(!userInputModified){this._widthOverrideElement.value=metrics.widthToInput();this._heightOverrideElement.value=metrics.heightToInput();this._deviceScaleFactorOverrideElement.value=metrics.deviceScaleFactorToInput();this._textAutosizingOverrideCheckbox.checked=metrics.textAutosizing;}
649 if(metrics.isValid()){var value=metrics.toSetting();if(value!==WebInspector.settings.deviceMetrics.get())
650 WebInspector.settings.deviceMetrics.set(value);}},_createDeviceMetricsElement:function(metrics)
651 {var fieldsetElement=WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.overrideDeviceMetrics);if(WebInspector.OverridesSupport.isInspectingDevice())
652 fieldsetElement.disabled=true;fieldsetElement.id="metrics-override-section";function swapDimensionsClicked()
653 {var widthValue=this._widthOverrideElement.value;this._widthOverrideElement.value=this._heightOverrideElement.value;this._heightOverrideElement.value=widthValue;this._applyDeviceMetricsUserInput();}
654 var tableElement=fieldsetElement.createChild("table","nowrap");var rowElement=tableElement.createChild("tr");var cellElement=rowElement.createChild("td");cellElement.appendChild(document.createTextNode(WebInspector.UIString("Resolution:")));cellElement=rowElement.createChild("td");this._widthOverrideElement=this._createInput(cellElement,"metrics-override-width",String(metrics.width||screen.width),this._applyDeviceMetricsUserInput.bind(this),true);this._swapDimensionsElement=cellElement.createChild("button","overrides-swap");this._swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 "));this._swapDimensionsElement.title=WebInspector.UIString("Swap dimensions");this._swapDimensionsElement.addEventListener("click",swapDimensionsClicked.bind(this),false);this._swapDimensionsElement.tabIndex=-1;this._heightOverrideElement=this._createInput(cellElement,"metrics-override-height",String(metrics.height||screen.height),this._applyDeviceMetricsUserInput.bind(this),true);rowElement=tableElement.createChild("tr");cellElement=rowElement.createChild("td");cellElement.colSpan=4;this._widthRangeInput=cellElement.createChild("input");this._widthRangeInput.type="range";this._widthRangeInput.min=100;this._widthRangeInput.max=2000;this._widthRangeInput.addEventListener("change",this._rangeValueChanged.bind(this),false);this._widthRangeInput.addEventListener("input",this._rangeValueChanged.bind(this),false);this._widthRangeInput.value=this._widthOverrideElement.value;rowElement=tableElement.createChild("tr");rowElement.title=WebInspector.UIString("Ratio between a device's physical pixels and device-independent pixels.");cellElement=rowElement.createChild("td");cellElement.appendChild(document.createTextNode(WebInspector.UIString("Device pixel ratio:")));cellElement=rowElement.createChild("td");this._deviceScaleFactorOverrideElement=this._createInput(cellElement,"metrics-override-device-scale",String(metrics.deviceScaleFactor||1),this._applyDeviceMetricsUserInput.bind(this),true);var textAutosizingOverrideElement=this._createNonPersistedCheckbox(WebInspector.UIString("Enable text autosizing "),this._applyDeviceMetricsUserInput.bind(this));textAutosizingOverrideElement.title=WebInspector.UIString("Text autosizing is the feature that boosts font sizes on mobile devices.");this._textAutosizingOverrideCheckbox=textAutosizingOverrideElement.firstChild;this._textAutosizingOverrideCheckbox.checked=metrics.textAutosizing;fieldsetElement.appendChild(textAutosizingOverrideElement);var checkbox=this._createSettingCheckbox(WebInspector.UIString("Emulate viewport"),WebInspector.settings.emulateViewport);fieldsetElement.appendChild(checkbox);checkbox=this._createSettingCheckbox(WebInspector.UIString("Shrink to fit"),WebInspector.settings.deviceFitWindow);fieldsetElement.appendChild(checkbox);return fieldsetElement;},_updateDeviceMetricsElement:function()
655 {const metricsSetting=WebInspector.settings.deviceMetrics.get();var metrics=WebInspector.OverridesSupport.DeviceMetrics.parseSetting(metricsSetting);if(this._widthOverrideElement.value!==metrics.width)
656 this._widthOverrideElement.value=metrics.width||screen.width;this._muteRangeListener=true;if(this._widthRangeInput.value!=metrics.width)
657 this._widthRangeInput.value=metrics.width||screen.width;delete this._muteRangeListener;if(this._heightOverrideElement.value!==metrics.height)
658 this._heightOverrideElement.value=metrics.height||screen.height;if(this._deviceScaleFactorOverrideElement.value!==metrics.deviceScaleFactor)
659 this._deviceScaleFactorOverrideElement.value=metrics.deviceScaleFactor||1;if(this._textAutosizingOverrideCheckbox.checked!==metrics.textAutosizing)
660 this._textAutosizingOverrideCheckbox.checked=metrics.textAutosizing||false;},_createMediaEmulationFragment:function()
661 {var checkbox=WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("CSS media"),WebInspector.settings.overrideCSSMedia,true);var fieldsetElement=WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.overrideCSSMedia);if(WebInspector.OverridesSupport.isInspectingDevice())
662 fieldsetElement.disabled=true;var mediaSelectElement=fieldsetElement.createChild("select");var mediaTypes=WebInspector.CSSStyleModel.MediaTypes;var defaultMedia=WebInspector.settings.emulatedCSSMedia.get();for(var i=0;i<mediaTypes.length;++i){var mediaType=mediaTypes[i];if(mediaType==="all"){continue;}
663 var option=document.createElement("option");option.text=mediaType;option.value=mediaType;mediaSelectElement.add(option);if(mediaType===defaultMedia)
664 mediaSelectElement.selectedIndex=mediaSelectElement.options.length-1;}
665 mediaSelectElement.addEventListener("change",this._emulateMediaChanged.bind(this,mediaSelectElement),false);var fragment=document.createDocumentFragment();fragment.appendChild(checkbox);fragment.appendChild(fieldsetElement);return fragment;},_emulateMediaChanged:function(select)
666 {var media=select.options[select.selectedIndex].value;WebInspector.settings.emulatedCSSMedia.set(media);},_rangeValueChanged:function()
667 {if(this._muteRangeListener)
668 return;this._widthOverrideElement.value=this._widthRangeInput.value;this._applyDeviceMetricsUserInput();},__proto__:WebInspector.OverridesView.Tab.prototype}
669 WebInspector.OverridesView.UserAgentTab=function()
670 {WebInspector.OverridesView.Tab.call(this,"user-agent",WebInspector.UIString("User Agent"),[WebInspector.settings.overrideUserAgent]);this.element.classList.add("overrides-user-agent");var checkbox=this._createSettingCheckbox(WebInspector.UIString("Spoof user agent"),WebInspector.settings.overrideUserAgent);checkbox.firstChild.disabled=WebInspector.OverridesSupport.isInspectingDevice();this.element.appendChild(checkbox);this.element.appendChild(this._createUserAgentSelectRowElement());}
671 WebInspector.OverridesView.UserAgentTab._userAgents=[["Android 4.0.2 \u2014 Galaxy Nexus","Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"],["Android 2.3 \u2014 Nexus S","Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"],["BlackBerry \u2014 BB10","Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"],["BlackBerry \u2014 PlayBook 2.1","Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+"],["BlackBerry \u2014 9900","Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534.11+"],["Chrome 31 \u2014 Mac","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"],["Chrome 31 \u2014 Windows","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"],["Chrome \u2014 Android Tablet","Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19"],["Chrome \u2014 Android Mobile","Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"],["Firefox 14 \u2014 Android Mobile","Mozilla/5.0 (Android; Mobile; rv:14.0) Gecko/14.0 Firefox/14.0"],["Firefox 14 \u2014 Android Tablet","Mozilla/5.0 (Android; Tablet; rv:14.0) Gecko/14.0 Firefox/14.0"],["Firefox 4 \u2014 Mac","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"],["Firefox 4 \u2014 Windows","Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"],["Firefox 7 \u2014 Mac","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"],["Firefox 7 \u2014 Windows","Mozilla/5.0 (Windows NT 6.1; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"],["Internet Explorer 10","Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"],["Internet Explorer 7","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"],["Internet Explorer 8","Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)"],["Internet Explorer 9","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"],["iPad \u2014 iOS 7","Mozilla/5.0 (iPad; CPU OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537.53"],["iPad \u2014 iOS 6","Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"],["iPhone \u2014 iOS 7","Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A4449d Safari/9537.53"],["iPhone \u2014 iOS 6","Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"],["MeeGo \u2014 Nokia N9","Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"],["Opera 18 \u2014 Mac","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.1284.68"],["Opera 18 \u2014 Windows","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.1284.68"],["Opera 12 \u2014 Mac","Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Presto/2.12.388 Version/12.16"],["Opera 12 \u2014 Windows","Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.16"],];WebInspector.OverridesView.UserAgentTab.prototype={_createUserAgentSelectRowElement:function()
672 {var userAgent=WebInspector.settings.userAgent.get();var userAgents=WebInspector.OverridesView.UserAgentTab._userAgents.concat([[WebInspector.UIString("Other"),"Other"]]);var fieldsetElement=WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.overrideUserAgent);if(WebInspector.OverridesSupport.isInspectingDevice())
673 fieldsetElement.disabled=true;this._selectElement=fieldsetElement.createChild("select");fieldsetElement.createChild("br");this._otherUserAgentElement=fieldsetElement.createChild("input");this._otherUserAgentElement.type="text";this._otherUserAgentElement.value=userAgent;this._otherUserAgentElement.title=userAgent;var selectionRestored=false;for(var i=0;i<userAgents.length;++i){var agent=userAgents[i];var option=new Option(agent[0],agent[1]);option._metrics=agent[2]?agent[2]:"";this._selectElement.add(option);if(userAgent===agent[1]){this._selectElement.selectedIndex=i;selectionRestored=true;}}
674 if(!selectionRestored){if(!userAgent)
675 this._selectElement.selectedIndex=0;else
676 this._selectElement.selectedIndex=userAgents.length-1;}
677 this._selectElement.addEventListener("change",this._userAgentChanged.bind(this,true),false);WebInspector.settings.userAgent.addChangeListener(this._userAgentSettingChanged,this);fieldsetElement.addEventListener("dblclick",textDoubleClicked.bind(this),false);this._otherUserAgentElement.addEventListener("blur",textChanged.bind(this),false);function textDoubleClicked()
678 {this._selectElement.selectedIndex=userAgents.length-1;this._userAgentChanged();}
679 function textChanged()
680 {if(WebInspector.settings.userAgent.get()!==this._otherUserAgentElement.value)
681 WebInspector.settings.userAgent.set(this._otherUserAgentElement.value);}
682 return fieldsetElement;},_userAgentChanged:function(isUserGesture)
683 {var value=this._selectElement.options[this._selectElement.selectedIndex].value;if(value!=="Other"){WebInspector.settings.userAgent.set(value);this._otherUserAgentElement.value=value;this._otherUserAgentElement.title=value;this._otherUserAgentElement.disabled=true;}else{this._otherUserAgentElement.disabled=false;this._otherUserAgentElement.focus();}},_userAgentSettingChanged:function()
684 {var value=WebInspector.settings.userAgent.get();var options=this._selectElement.options;var foundMatch=false;for(var i=0;i<options.length;++i){if(options[i].value===value){if(this._selectElement.selectedIndex!==i)
685 this._selectElement.selectedIndex=i;foundMatch=true;break;}}
686 this._otherUserAgentElement.disabled=foundMatch;if(!foundMatch)
687 this._selectElement.selectedIndex=options.length-1;if(this._otherUserAgentElement.value!==value){this._otherUserAgentElement.value=value;this._otherUserAgentElement.title=value;}},__proto__:WebInspector.OverridesView.Tab.prototype}
688 WebInspector.OverridesView.SensorsTab=function()
689 {WebInspector.OverridesView.Tab.call(this,"sensors",WebInspector.UIString("Sensors"),[WebInspector.settings.emulateTouchEvents,WebInspector.settings.overrideGeolocation,WebInspector.settings.overrideDeviceOrientation]);this.element.classList.add("overrides-sensors");this.registerRequiredCSS("accelerometer.css");if(!WebInspector.OverridesSupport.isInspectingDevice())
690 this.element.appendChild(this._createSettingCheckbox(WebInspector.UIString("Emulate touch screen"),WebInspector.settings.emulateTouchEvents));this._appendGeolocationOverrideControl();this._apendDeviceOrientationOverrideControl();}
691 WebInspector.OverridesView.SensorsTab.prototype={_appendGeolocationOverrideControl:function()
692 {const geolocationSetting=WebInspector.settings.geolocationOverride.get();var geolocation=WebInspector.OverridesSupport.GeolocationPosition.parseSetting(geolocationSetting);this.element.appendChild(this._createSettingCheckbox(WebInspector.UIString("Emulate geolocation coordinates"),WebInspector.settings.overrideGeolocation,this._geolocationOverrideCheckboxClicked.bind(this)));this.element.appendChild(this._createGeolocationOverrideElement(geolocation));this._geolocationOverrideCheckboxClicked(WebInspector.settings.overrideGeolocation.get());},_geolocationOverrideCheckboxClicked:function(enabled)
693 {if(enabled&&!this._latitudeElement.value)
694 this._latitudeElement.focus();},_applyGeolocationUserInput:function()
695 {this._setGeolocationPosition(WebInspector.OverridesSupport.GeolocationPosition.parseUserInput(this._latitudeElement.value.trim(),this._longitudeElement.value.trim(),this._geolocationErrorElement.checked),true);},_setGeolocationPosition:function(geolocation,userInputModified)
696 {if(!geolocation)
697 return;if(!userInputModified){this._latitudeElement.value=geolocation.latitude;this._longitudeElement.value=geolocation.longitude;}
698 var value=geolocation.toSetting();WebInspector.settings.geolocationOverride.set(value);},_createGeolocationOverrideElement:function(geolocation)
699 {var fieldsetElement=WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.overrideGeolocation);fieldsetElement.id="geolocation-override-section";var tableElement=fieldsetElement.createChild("table");var rowElement=tableElement.createChild("tr");var cellElement=rowElement.createChild("td");cellElement=rowElement.createChild("td");cellElement.appendChild(document.createTextNode(WebInspector.UIString("Lat = ")));this._latitudeElement=this._createInput(cellElement,"geolocation-override-latitude",String(geolocation.latitude),this._applyGeolocationUserInput.bind(this),true);cellElement.appendChild(document.createTextNode(" , "));cellElement.appendChild(document.createTextNode(WebInspector.UIString("Lon = ")));this._longitudeElement=this._createInput(cellElement,"geolocation-override-longitude",String(geolocation.longitude),this._applyGeolocationUserInput.bind(this),true);rowElement=tableElement.createChild("tr");cellElement=rowElement.createChild("td");cellElement.colSpan=2;var geolocationErrorLabelElement=document.createElement("label");var geolocationErrorCheckboxElement=geolocationErrorLabelElement.createChild("input");geolocationErrorCheckboxElement.id="geolocation-error";geolocationErrorCheckboxElement.type="checkbox";geolocationErrorCheckboxElement.checked=!geolocation||geolocation.error;geolocationErrorCheckboxElement.addEventListener("click",this._applyGeolocationUserInput.bind(this),false);geolocationErrorLabelElement.appendChild(document.createTextNode(WebInspector.UIString("Emulate position unavailable")));this._geolocationErrorElement=geolocationErrorCheckboxElement;cellElement.appendChild(geolocationErrorLabelElement);return fieldsetElement;},_apendDeviceOrientationOverrideControl:function()
700 {const deviceOrientationSetting=WebInspector.settings.deviceOrientationOverride.get();var deviceOrientation=WebInspector.OverridesSupport.DeviceOrientation.parseSetting(deviceOrientationSetting);this.element.appendChild(this._createSettingCheckbox(WebInspector.UIString("Accelerometer"),WebInspector.settings.overrideDeviceOrientation,this._deviceOrientationOverrideCheckboxClicked.bind(this)));this.element.appendChild(this._createDeviceOrientationOverrideElement(deviceOrientation));this._deviceOrientationOverrideCheckboxClicked(WebInspector.settings.overrideDeviceOrientation.get());},_deviceOrientationOverrideCheckboxClicked:function(enabled)
701 {if(enabled&&!this._alphaElement.value)
702 this._alphaElement.focus();},_applyDeviceOrientationUserInput:function()
703 {this._setDeviceOrientation(WebInspector.OverridesSupport.DeviceOrientation.parseUserInput(this._alphaElement.value.trim(),this._betaElement.value.trim(),this._gammaElement.value.trim()),WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource.UserInput);},_resetDeviceOrientation:function()
704 {this._setDeviceOrientation(new WebInspector.OverridesSupport.DeviceOrientation(0,0,0),WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource.ResetButton);},_setDeviceOrientation:function(deviceOrientation,modificationSource)
705 {if(!deviceOrientation)
706 return;if(modificationSource!=WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource.UserInput){this._alphaElement.value=deviceOrientation.alpha;this._betaElement.value=deviceOrientation.beta;this._gammaElement.value=deviceOrientation.gamma;}
707 if(modificationSource!=WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource.UserDrag)
708 this._setBoxOrientation(deviceOrientation);var value=deviceOrientation.toSetting();WebInspector.settings.deviceOrientationOverride.set(value);},_createAxisInput:function(parentElement,id,label,defaultText)
709 {var div=parentElement.createChild("div","accelerometer-axis-input-container");div.appendChild(document.createTextNode(label));return this._createInput(div,id,defaultText,this._applyDeviceOrientationUserInput.bind(this),true);},_createDeviceOrientationOverrideElement:function(deviceOrientation)
710 {var fieldsetElement=WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.overrideDeviceOrientation);fieldsetElement.id="device-orientation-override-section";var tableElement=fieldsetElement.createChild("table");var rowElement=tableElement.createChild("tr");var cellElement=rowElement.createChild("td","accelerometer-inputs-cell");this._alphaElement=this._createAxisInput(cellElement,"device-orientation-override-alpha","\u03B1: ",String(deviceOrientation.alpha));this._betaElement=this._createAxisInput(cellElement,"device-orientation-override-beta","\u03B2: ",String(deviceOrientation.beta));this._gammaElement=this._createAxisInput(cellElement,"device-orientation-override-gamma","\u03B3: ",String(deviceOrientation.gamma));var resetButton=cellElement.createChild("button","settings-tab-text-button accelerometer-reset-button");resetButton.textContent=WebInspector.UIString("Reset");resetButton.addEventListener("click",this._resetDeviceOrientation.bind(this),false);this._stageElement=rowElement.createChild("td","accelerometer-stage");this._boxElement=this._stageElement.createChild("section","accelerometer-box");this._boxElement.createChild("section","front");this._boxElement.createChild("section","top");this._boxElement.createChild("section","back");this._boxElement.createChild("section","left");this._boxElement.createChild("section","right");this._boxElement.createChild("section","bottom");WebInspector.installDragHandle(this._stageElement,this._onBoxDragStart.bind(this),this._onBoxDrag.bind(this),this._onBoxDragEnd.bind(this),"move");this._setBoxOrientation(deviceOrientation);return fieldsetElement;},_setBoxOrientation:function(deviceOrientation)
711 {var matrix=new WebKitCSSMatrix();this._boxMatrix=matrix.rotate(-deviceOrientation.beta,deviceOrientation.gamma,-deviceOrientation.alpha);this._boxElement.style.webkitTransform=this._boxMatrix.toString();},_onBoxDrag:function(event)
712 {var mouseMoveVector=this._calculateRadiusVector(event.x,event.y);if(!mouseMoveVector)
713 return true;event.consume(true);var axis=WebInspector.Geometry.crossProduct(this._mouseDownVector,mouseMoveVector);axis.normalize();var angle=WebInspector.Geometry.calculateAngle(this._mouseDownVector,mouseMoveVector);var matrix=new WebKitCSSMatrix();var rotationMatrix=matrix.rotateAxisAngle(axis.x,axis.y,axis.z,angle);this._currentMatrix=rotationMatrix.multiply(this._boxMatrix)
714 this._boxElement.style.webkitTransform=this._currentMatrix;var eulerAngles=WebInspector.Geometry.EulerAngles.fromRotationMatrix(this._currentMatrix);var newOrientation=new WebInspector.OverridesSupport.DeviceOrientation(-eulerAngles.alpha,-eulerAngles.beta,eulerAngles.gamma);this._setDeviceOrientation(newOrientation,WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource.UserDrag);return false;},_onBoxDragStart:function(event)
715 {if(!WebInspector.settings.overrideDeviceOrientation.get())
716 return false;this._mouseDownVector=this._calculateRadiusVector(event.x,event.y);if(!this._mouseDownVector)
717 return false;event.consume(true);return true;},_onBoxDragEnd:function()
718 {this._boxMatrix=this._currentMatrix;},_calculateRadiusVector:function(x,y)
719 {var rect=this._stageElement.getBoundingClientRect();var radius=Math.max(rect.width,rect.height)/2;var sphereX=(x-rect.left-rect.width/2)/radius;var sphereY=(y-rect.top-rect.height/2)/radius;var sqrSum=sphereX*sphereX+sphereY*sphereY;if(sqrSum>0.5)
720 return new WebInspector.Geometry.Vector(sphereX,sphereY,0.5/Math.sqrt(sqrSum));return new WebInspector.Geometry.Vector(sphereX,sphereY,Math.sqrt(1-sqrSum));},__proto__:WebInspector.OverridesView.Tab.prototype}
721 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource={UserInput:"userInput",UserDrag:"userDrag",ResetButton:"resetButton"};WebInspector.PlatformFontsSidebarPane=function()
722 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Fonts"));this.element.classList.add("platform-fonts");WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified,this._onNodeChange.bind(this));WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved,this._onNodeChange.bind(this));WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.CharacterDataModified,this._onNodeChange.bind(this));this._sectionTitle=document.createElementWithClass("div","sidebar-separator");this.element.insertBefore(this._sectionTitle,this.bodyElement);this._sectionTitle.textContent=WebInspector.UIString("Rendered Fonts");this._fontStatsSection=this.bodyElement.createChild("div","stats-section");}
723 WebInspector.PlatformFontsSidebarPane.prototype={_onNodeChange:function()
724 {if(this._innerUpdateTimeout)
725 return;this._innerUpdateTimeout=setTimeout(this._innerUpdate.bind(this),100);},update:function(node)
726 {if(!node){delete this._node;return;}
727 this._node=node;this._innerUpdate();},_innerUpdate:function()
728 {if(this._innerUpdateTimeout){clearTimeout(this._innerUpdateTimeout);delete this._innerUpdateTimeout;}
729 if(!this._node)
730 return;WebInspector.cssModel.getPlatformFontsForNode(this._node.id,this._refreshUI.bind(this,this._node));},_refreshUI:function(node,cssFamilyName,platformFonts)
731 {if(this._node!==node)
732 return;this._fontStatsSection.removeChildren();var isEmptySection=!platformFonts||!platformFonts.length;this._sectionTitle.classList.toggle("hidden",isEmptySection);if(isEmptySection)
733 return;platformFonts.sort(function(a,b){return b.glyphCount-a.glyphCount;});for(var i=0;i<platformFonts.length;++i){var fontStatElement=this._fontStatsSection.createChild("div","font-stats-item");var fontNameElement=fontStatElement.createChild("span","font-name");fontNameElement.textContent=platformFonts[i].familyName;var fontDelimeterElement=fontStatElement.createChild("span","delimeter");fontDelimeterElement.textContent="\u2014";var fontUsageElement=fontStatElement.createChild("span","font-usage");var usage=platformFonts[i].glyphCount;fontUsageElement.textContent=usage===1?WebInspector.UIString("%d glyph",usage):WebInspector.UIString("%d glyphs",usage);}},__proto__:WebInspector.SidebarPane.prototype};WebInspector.PropertiesSidebarPane=function()
734 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Properties"));}
735 WebInspector.PropertiesSidebarPane._objectGroupName="properties-sidebar-pane";WebInspector.PropertiesSidebarPane.prototype={update:function(node)
736 {var body=this.bodyElement;if(!node){body.removeChildren();this.sections=[];return;}
737 WebInspector.RemoteObject.resolveNode(node,WebInspector.PropertiesSidebarPane._objectGroupName,nodeResolved.bind(this));function nodeResolved(object)
738 {if(!object)
739 return;function protoList()
740 {var proto=this;var result={};var counter=1;while(proto){result[counter++]=proto;proto=proto.__proto__;}
741 return result;}
742 object.callFunction(protoList,undefined,nodePrototypesReady.bind(this));object.release();}
743 function nodePrototypesReady(object,wasThrown)
744 {if(!object||wasThrown)
745 return;object.getOwnProperties(fillSection.bind(this));}
746 function fillSection(prototypes)
747 {if(!prototypes)
748 return;var body=this.bodyElement;body.removeChildren();this.sections=[];for(var i=0;i<prototypes.length;++i){if(!parseInt(prototypes[i].name,10))
749 continue;var prototype=prototypes[i].value;var title=prototype.description;if(title.match(/Prototype$/))
750 title=title.replace(/Prototype$/,"");var section=new WebInspector.ObjectPropertiesSection(prototype,title);this.sections.push(section);body.appendChild(section.element);}}},__proto__:WebInspector.SidebarPane.prototype};WebInspector.RenderingOptionsView=function()
751 {WebInspector.VBox.call(this);this.registerRequiredCSS("helpScreen.css");this.element.classList.add("help-indent-labels");var div=this.element.createChild("div","settings-tab help-content help-container help-no-columns");div.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show paint rectangles"),WebInspector.settings.showPaintRects));div.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show composited layer borders"),WebInspector.settings.showDebugBorders));div.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show FPS meter"),WebInspector.settings.showFPSCounter));div.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Enable continuous page repainting"),WebInspector.settings.continuousPainting));var child=WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show potential scroll bottlenecks"),WebInspector.settings.showScrollBottleneckRects);child.title=WebInspector.UIString("Shows areas of the page that slow down scrolling:\nTouch and mousewheel event listeners can delay scrolling.\nSome areas need to repaint their content when scrolled.");div.appendChild(child);}
752 WebInspector.RenderingOptionsView.prototype={__proto__:WebInspector.VBox.prototype};WebInspector.StylesSidebarPane=function(computedStylePane,setPseudoClassCallback)
753 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Styles"));this._elementStateButton=document.createElement("button");this._elementStateButton.className="pane-title-button element-state";this._elementStateButton.title=WebInspector.UIString("Toggle Element State");this._elementStateButton.addEventListener("click",this._toggleElementStatePane.bind(this),false);this.titleElement.appendChild(this._elementStateButton);var addButton=document.createElement("button");addButton.className="pane-title-button add";addButton.id="add-style-button-test-id";addButton.title=WebInspector.UIString("New Style Rule");addButton.addEventListener("click",this._createNewRule.bind(this),false);this.titleElement.appendChild(addButton);this._computedStylePane=computedStylePane;computedStylePane.setHostingPane(this);this._setPseudoClassCallback=setPseudoClassCallback;this.element.addEventListener("contextmenu",this._contextMenuEventFired.bind(this),true);WebInspector.settings.colorFormat.addChangeListener(this._colorFormatSettingChanged.bind(this));this._createElementStatePane();this.bodyElement.appendChild(this._elementStatePane);this._sectionsContainer=document.createElement("div");this.bodyElement.appendChild(this._sectionsContainer);this._spectrumHelper=new WebInspector.SpectrumPopupHelper();this._linkifier=new WebInspector.Linkifier(new WebInspector.Linkifier.DefaultCSSFormatter());WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded,this._styleSheetOrMediaQueryResultChanged,this);WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved,this._styleSheetOrMediaQueryResultChanged,this);WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetChanged,this._styleSheetOrMediaQueryResultChanged,this);WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.MediaQueryResultChanged,this._styleSheetOrMediaQueryResultChanged,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified,this._attributeChanged,this);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved,this._attributeChanged,this);WebInspector.settings.showUserAgentStyles.addChangeListener(this._showUserAgentStylesSettingChanged.bind(this));WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameResized,this._frameResized,this);this.element.classList.add("styles-pane");this.element.classList.toggle("show-user-styles",WebInspector.settings.showUserAgentStyles.get());this.element.addEventListener("mousemove",this._mouseMovedOverElement.bind(this),false);document.body.addEventListener("keydown",this._keyDown.bind(this),false);document.body.addEventListener("keyup",this._keyUp.bind(this),false);}
754 WebInspector.StylesSidebarPane.PseudoIdNames=["","first-line","first-letter","before","after","selection","","-webkit-scrollbar","-webkit-file-upload-button","-webkit-input-placeholder","-webkit-slider-thumb","-webkit-search-cancel-button","-webkit-search-decoration","-webkit-search-results-decoration","-webkit-search-results-button","-webkit-media-controls-panel","-webkit-media-controls-play-button","-webkit-media-controls-mute-button","-webkit-media-controls-timeline","-webkit-media-controls-timeline-container","-webkit-media-controls-volume-slider","-webkit-media-controls-volume-slider-container","-webkit-media-controls-current-time-display","-webkit-media-controls-time-remaining-display","-webkit-media-controls-fullscreen-button","-webkit-media-controls-toggle-closed-captions-button","-webkit-media-controls-status-display","-webkit-scrollbar-thumb","-webkit-scrollbar-button","-webkit-scrollbar-track","-webkit-scrollbar-track-piece","-webkit-scrollbar-corner","-webkit-resizer","-webkit-inner-spin-button","-webkit-outer-spin-button"];WebInspector.StylesSidebarPane._colorRegex=/((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}|\b\w+\b(?!-))/g;WebInspector.StylesSidebarPane.createExclamationMark=function(property)
755 {var exclamationElement=document.createElement("div");exclamationElement.className="exclamation-mark"+(WebInspector.StylesSidebarPane._ignoreErrorsForProperty(property)?"":" warning-icon-small");exclamationElement.title=WebInspector.CSSMetadata.cssPropertiesMetainfo.keySet()[property.name.toLowerCase()]?WebInspector.UIString("Invalid property value."):WebInspector.UIString("Unknown property name.");return exclamationElement;}
756 WebInspector.StylesSidebarPane._colorFormat=function(color)
757 {const cf=WebInspector.Color.Format;var format;var formatSetting=WebInspector.settings.colorFormat.get();if(formatSetting===cf.Original)
758 format=cf.Original;else if(formatSetting===cf.RGB)
759 format=(color.hasAlpha()?cf.RGBA:cf.RGB);else if(formatSetting===cf.HSL)
760 format=(color.hasAlpha()?cf.HSLA:cf.HSL);else if(!color.hasAlpha())
761 format=(color.canBeShortHex()?cf.ShortHEX:cf.HEX);else
762 format=cf.RGBA;return format;}
763 WebInspector.StylesSidebarPane._ignoreErrorsForProperty=function(property){function hasUnknownVendorPrefix(string)
764 {return!string.startsWith("-webkit-")&&/^[-_][\w\d]+-\w/.test(string);}
765 var name=property.name.toLowerCase();if(name.charAt(0)==="_")
766 return true;if(name==="filter")
767 return true;if(name.startsWith("scrollbar-"))
768 return true;if(hasUnknownVendorPrefix(name))
769 return true;var value=property.value.toLowerCase();if(value.endsWith("\9"))
770 return true;if(hasUnknownVendorPrefix(value))
771 return true;return false;}
772 WebInspector.StylesSidebarPane.prototype={_contextMenuEventFired:function(event)
773 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApplicableItems((event.target));contextMenu.show();},setFilterBoxContainers:function(matchedStylesElement,computedStylesElement)
774 {matchedStylesElement.appendChild(this._createCSSFilterControl());this._computedStylePane.setFilterBoxContainer(computedStylesElement);},_createCSSFilterControl:function()
775 {var filterInput=this._createPropertyFilterElement(false,searchHandler.bind(this));function searchHandler(regex)
776 {this._filterRegex=regex;}
777 return filterInput;},get _forcedPseudoClasses()
778 {return this.node?(this.node.getUserProperty("pseudoState")||undefined):undefined;},_updateForcedPseudoStateInputs:function()
779 {if(!this.node)
780 return;var hasPseudoType=!!this.node.pseudoType();this._elementStateButton.classList.toggle("hidden",hasPseudoType);this._elementStatePane.classList.toggle("expanded",!hasPseudoType&&this._elementStateButton.classList.contains("toggled"));var nodePseudoState=this._forcedPseudoClasses;if(!nodePseudoState)
781 nodePseudoState=[];var inputs=this._elementStatePane.inputs;for(var i=0;i<inputs.length;++i)
782 inputs[i].checked=nodePseudoState.indexOf(inputs[i].state)>=0;},update:function(node,forceUpdate)
783 {this._spectrumHelper.hide();this._discardElementUnderMouse();var refresh=false;if(forceUpdate)
784 delete this.node;if(!forceUpdate&&(node===this.node))
785 refresh=true;if(node&&node.nodeType()===Node.TEXT_NODE&&node.parentNode)
786 node=node.parentNode;if(node&&node.nodeType()!==Node.ELEMENT_NODE)
787 node=null;if(node)
788 this.node=node;else
789 node=this.node;this._updateForcedPseudoStateInputs();if(refresh)
790 this._refreshUpdate();else
791 this._rebuildUpdate();},_refreshUpdate:function(editedSection,forceFetchComputedStyle,userCallback)
792 {var callbackWrapper=function()
793 {if(this._filterRegex)
794 this._updateFilter(false);if(userCallback)
795 userCallback();}.bind(this);if(this._refreshUpdateInProgress){this._lastNodeForInnerRefresh=this.node;return;}
796 var node=this._validateNode(userCallback);if(!node)
797 return;function computedStyleCallback(computedStyle)
798 {delete this._refreshUpdateInProgress;if(this._lastNodeForInnerRefresh){delete this._lastNodeForInnerRefresh;this._refreshUpdate(editedSection,forceFetchComputedStyle,callbackWrapper);return;}
799 if(this.node===node&&computedStyle)
800 this._innerRefreshUpdate(node,computedStyle,editedSection);callbackWrapper();}
801 if(this._computedStylePane.isShowing()||forceFetchComputedStyle){this._refreshUpdateInProgress=true;WebInspector.cssModel.getComputedStyleAsync(node.id,computedStyleCallback.bind(this));}else{this._innerRefreshUpdate(node,null,editedSection);callbackWrapper();}},_rebuildUpdate:function()
802 {if(this._rebuildUpdateInProgress){this._lastNodeForInnerRebuild=this.node;return;}
803 var node=this._validateNode();if(!node)
804 return;this._rebuildUpdateInProgress=true;var resultStyles={};function stylesCallback(matchedResult)
805 {delete this._rebuildUpdateInProgress;var lastNodeForRebuild=this._lastNodeForInnerRebuild;if(lastNodeForRebuild){delete this._lastNodeForInnerRebuild;if(lastNodeForRebuild!==this.node){this._rebuildUpdate();return;}}
806 if(matchedResult&&this.node===node){resultStyles.matchedCSSRules=matchedResult.matchedCSSRules;resultStyles.pseudoElements=matchedResult.pseudoElements;resultStyles.inherited=matchedResult.inherited;this._innerRebuildUpdate(node,resultStyles);}
807 if(lastNodeForRebuild){this._rebuildUpdate();return;}}
808 function inlineCallback(inlineStyle,attributesStyle)
809 {resultStyles.inlineStyle=inlineStyle;resultStyles.attributesStyle=attributesStyle;}
810 function computedCallback(computedStyle)
811 {resultStyles.computedStyle=computedStyle;}
812 if(this._computedStylePane.isShowing())
813 WebInspector.cssModel.getComputedStyleAsync(node.id,computedCallback);WebInspector.cssModel.getInlineStylesAsync(node.id,inlineCallback);WebInspector.cssModel.getMatchedStylesAsync(node.id,true,true,stylesCallback.bind(this));},_validateNode:function(userCallback)
814 {if(!this.node){this._sectionsContainer.removeChildren();this._computedStylePane.bodyElement.removeChildren();this.sections={};if(userCallback)
815 userCallback();return null;}
816 return this.node;},_styleSheetOrMediaQueryResultChanged:function()
817 {if(this._userOperation||this._isEditingStyle)
818 return;this._rebuildUpdate();},_frameResized:function()
819 {function refreshContents()
820 {this._rebuildUpdate();delete this._activeTimer;}
821 if(this._activeTimer)
822 clearTimeout(this._activeTimer);this._activeTimer=setTimeout(refreshContents.bind(this),100);},_attributeChanged:function(event)
823 {if(this._isEditingStyle||this._userOperation)
824 return;if(!this._canAffectCurrentStyles(event.data.node))
825 return;this._rebuildUpdate();},_canAffectCurrentStyles:function(node)
826 {return this.node&&(this.node===node||node.parentNode===this.node.parentNode||node.isAncestor(this.node));},_innerRefreshUpdate:function(node,computedStyle,editedSection)
827 {for(var pseudoId in this.sections){var styleRules=this._refreshStyleRules(this.sections[pseudoId],computedStyle);var usedProperties={};this._markUsedProperties(styleRules,usedProperties);this._refreshSectionsForStyleRules(styleRules,usedProperties,editedSection);}
828 if(computedStyle)
829 this.sections[0][0].rebuildComputedTrace(this.sections[0]);this._nodeStylesUpdatedForTest(node,false);},_innerRebuildUpdate:function(node,styles)
830 {this._sectionsContainer.removeChildren();this._computedStylePane.bodyElement.removeChildren();this._linkifier.reset();var styleRules=this._rebuildStyleRules(node,styles);var usedProperties={};this._markUsedProperties(styleRules,usedProperties);this.sections[0]=this._rebuildSectionsForStyleRules(styleRules,usedProperties,null);var anchorElement=this.sections[0].inheritedPropertiesSeparatorElement;if(styles.computedStyle)
831 this.sections[0][0].rebuildComputedTrace(this.sections[0]);for(var i=0;i<styles.pseudoElements.length;++i){var pseudoElementCSSRules=styles.pseudoElements[i];styleRules=[];var pseudoId=pseudoElementCSSRules.pseudoId;var entry={isStyleSeparator:true,pseudoId:pseudoId};styleRules.push(entry);for(var j=pseudoElementCSSRules.rules.length-1;j>=0;--j){var rule=pseudoElementCSSRules.rules[j];styleRules.push({style:rule.style,selectorText:rule.selectorText,media:rule.media,sourceURL:rule.resourceURL(),rule:rule,editable:!!(rule.style&&rule.style.id)});}
832 usedProperties={};this._markUsedProperties(styleRules,usedProperties);this.sections[pseudoId]=this._rebuildSectionsForStyleRules(styleRules,usedProperties,anchorElement);}
833 if(this._filterRegex)
834 this._updateFilter(false);this._nodeStylesUpdatedForTest(node,true);},_nodeStylesUpdatedForTest:function(node,rebuild)
835 {},_refreshStyleRules:function(sections,computedStyle)
836 {var nodeComputedStyle=computedStyle;var styleRules=[];for(var i=0;sections&&i<sections.length;++i){var section=sections[i];if(section.isBlank)
837 continue;if(section.computedStyle)
838 section.styleRule.style=nodeComputedStyle;var styleRule={section:section,style:section.styleRule.style,computedStyle:section.computedStyle,rule:section.rule,editable:!!(section.styleRule.style&&section.styleRule.style.id),isAttribute:section.styleRule.isAttribute,isInherited:section.styleRule.isInherited,parentNode:section.styleRule.parentNode};styleRules.push(styleRule);}
839 return styleRules;},_rebuildStyleRules:function(node,styles)
840 {var nodeComputedStyle=styles.computedStyle;this.sections={};var styleRules=[];function addAttributesStyle()
841 {if(!styles.attributesStyle)
842 return;var attrStyle={style:styles.attributesStyle,editable:false};attrStyle.selectorText=node.nodeNameInCorrectCase()+"["+WebInspector.UIString("Attributes Style")+"]";styleRules.push(attrStyle);}
843 styleRules.push({computedStyle:true,selectorText:"",style:nodeComputedStyle,editable:false});if(!!node.pseudoType())
844 styleRules.push({isStyleSeparator:true,isPlaceholder:true});if(styles.inlineStyle&&node.nodeType()===Node.ELEMENT_NODE){var inlineStyle={selectorText:"element.style",style:styles.inlineStyle,isAttribute:true};styleRules.push(inlineStyle);}
845 var addedAttributesStyle;for(var i=styles.matchedCSSRules.length-1;i>=0;--i){var rule=styles.matchedCSSRules[i];if((rule.isUser||rule.isUserAgent)&&!addedAttributesStyle){addedAttributesStyle=true;addAttributesStyle();}
846 styleRules.push({style:rule.style,selectorText:rule.selectorText,media:rule.media,sourceURL:rule.resourceURL(),rule:rule,editable:!!(rule.style&&rule.style.id)});}
847 if(!addedAttributesStyle)
848 addAttributesStyle();var parentNode=node.parentNode;function insertInheritedNodeSeparator(node)
849 {var entry={};entry.isStyleSeparator=true;entry.node=node;styleRules.push(entry);}
850 for(var parentOrdinal=0;parentOrdinal<styles.inherited.length;++parentOrdinal){var parentStyles=styles.inherited[parentOrdinal];var separatorInserted=false;if(parentStyles.inlineStyle){if(this._containsInherited(parentStyles.inlineStyle)){var inlineStyle={selectorText:WebInspector.UIString("Style Attribute"),style:parentStyles.inlineStyle,isAttribute:true,isInherited:true,parentNode:parentNode};if(!separatorInserted){insertInheritedNodeSeparator(parentNode);separatorInserted=true;}
851 styleRules.push(inlineStyle);}}
852 for(var i=parentStyles.matchedCSSRules.length-1;i>=0;--i){var rulePayload=parentStyles.matchedCSSRules[i];if(!this._containsInherited(rulePayload.style))
853 continue;var rule=rulePayload;if(!separatorInserted){insertInheritedNodeSeparator(parentNode);separatorInserted=true;}
854 styleRules.push({style:rule.style,selectorText:rule.selectorText,media:rule.media,sourceURL:rule.resourceURL(),rule:rule,isInherited:true,parentNode:parentNode,editable:!!(rule.style&&rule.style.id)});}
855 parentNode=parentNode.parentNode;}
856 return styleRules;},_markUsedProperties:function(styleRules,usedProperties)
857 {var foundImportantProperties={};var propertyToEffectiveRule={};var inheritedPropertyToNode={};for(var i=0;i<styleRules.length;++i){var styleRule=styleRules[i];if(styleRule.computedStyle||styleRule.isStyleSeparator)
858 continue;if(styleRule.section&&styleRule.section.noAffect)
859 continue;styleRule.usedProperties={};var style=styleRule.style;var allProperties=style.allProperties;for(var j=0;j<allProperties.length;++j){var property=allProperties[j];if(!property.isLive||!property.parsedOk)
860 continue;if(styleRule.isInherited&&!WebInspector.CSSMetadata.isPropertyInherited(property.name))
861 continue;var canonicalName=WebInspector.CSSMetadata.canonicalPropertyName(property.name);if(foundImportantProperties.hasOwnProperty(canonicalName))
862 continue;if(!property.important&&usedProperties.hasOwnProperty(canonicalName))
863 continue;var isKnownProperty=propertyToEffectiveRule.hasOwnProperty(canonicalName);if(!isKnownProperty&&styleRule.isInherited&&!inheritedPropertyToNode[canonicalName])
864 inheritedPropertyToNode[canonicalName]=styleRule.parentNode;if(property.important){if(styleRule.isInherited&&isKnownProperty&&styleRule.parentNode!==inheritedPropertyToNode[canonicalName])
865 continue;foundImportantProperties[canonicalName]=true;if(isKnownProperty)
866 delete propertyToEffectiveRule[canonicalName].usedProperties[canonicalName];}
867 styleRule.usedProperties[canonicalName]=true;usedProperties[canonicalName]=true;propertyToEffectiveRule[canonicalName]=styleRule;}}},_refreshSectionsForStyleRules:function(styleRules,usedProperties,editedSection)
868 {for(var i=0;i<styleRules.length;++i){var styleRule=styleRules[i];var section=styleRule.section;if(styleRule.computedStyle){section._usedProperties=usedProperties;section.update();}else{section._usedProperties=styleRule.usedProperties;section.update(section===editedSection);}}},_rebuildSectionsForStyleRules:function(styleRules,usedProperties,anchorElement)
869 {var sections=[];for(var i=0;i<styleRules.length;++i){var styleRule=styleRules[i];if(styleRule.isStyleSeparator){var separatorElement=document.createElement("div");if(styleRule.isPlaceholder){separatorElement.className="styles-sidebar-placeholder";this._sectionsContainer.insertBefore(separatorElement,anchorElement);continue;}
870 separatorElement.className="sidebar-separator";if(styleRule.node){var link=WebInspector.DOMPresentationUtils.linkifyNodeReference(styleRule.node);separatorElement.appendChild(document.createTextNode(WebInspector.UIString("Inherited from")+" "));separatorElement.appendChild(link);if(!sections.inheritedPropertiesSeparatorElement)
871 sections.inheritedPropertiesSeparatorElement=separatorElement;}else if("pseudoId"in styleRule){var pseudoName=WebInspector.StylesSidebarPane.PseudoIdNames[styleRule.pseudoId];if(pseudoName)
872 separatorElement.textContent=WebInspector.UIString("Pseudo ::%s element",pseudoName);else
873 separatorElement.textContent=WebInspector.UIString("Pseudo element");}else
874 separatorElement.textContent=styleRule.text;this._sectionsContainer.insertBefore(separatorElement,anchorElement);continue;}
875 var computedStyle=styleRule.computedStyle;var editable=styleRule.editable;if(typeof editable==="undefined")
876 editable=true;if(computedStyle)
877 var section=new WebInspector.ComputedStylePropertiesSection(this,styleRule,usedProperties);else{var section=new WebInspector.StylePropertiesSection(this,styleRule,editable,styleRule.isInherited);section._markSelectorMatches();}
878 section.expanded=true;if(computedStyle)
879 this._computedStylePane.bodyElement.appendChild(section.element);else
880 this._sectionsContainer.insertBefore(section.element,anchorElement);sections.push(section);}
881 return sections;},_containsInherited:function(style)
882 {var properties=style.allProperties;for(var i=0;i<properties.length;++i){var property=properties[i];if(property.isLive&&WebInspector.CSSMetadata.isPropertyInherited(property.name))
883 return true;}
884 return false;},_colorFormatSettingChanged:function(event)
885 {for(var pseudoId in this.sections){var sections=this.sections[pseudoId];for(var i=0;i<sections.length;++i)
886 sections[i].update(true);}},_createNewRule:function(event)
887 {event.consume();this.expand();this.addBlankSection().startEditingSelector();},addBlankSection:function()
888 {var blankSection=new WebInspector.BlankStylePropertiesSection(this,this.node?WebInspector.DOMPresentationUtils.simpleSelector(this.node):"");var elementStyleSection=this.sections[0][1];this._sectionsContainer.insertBefore(blankSection.element,elementStyleSection.element.nextSibling);this.sections[0].splice(2,0,blankSection);return blankSection;},removeSection:function(section)
889 {for(var pseudoId in this.sections){var sections=this.sections[pseudoId];var index=sections.indexOf(section);if(index===-1)
890 continue;sections.splice(index,1);section.element.remove();}},_toggleElementStatePane:function(event)
891 {event.consume();var buttonToggled=!this._elementStateButton.classList.contains("toggled");if(buttonToggled)
892 this.expand();this._elementStateButton.classList.toggle("toggled",buttonToggled);this._elementStatePane.classList.toggle("expanded",buttonToggled);},_createElementStatePane:function()
893 {this._elementStatePane=document.createElement("div");this._elementStatePane.className="styles-element-state-pane source-code";var table=document.createElement("table");var inputs=[];this._elementStatePane.inputs=inputs;function clickListener(event)
894 {var node=this._validateNode();if(!node)
895 return;this._setPseudoClassCallback(node.id,event.target.state,event.target.checked);}
896 function createCheckbox(state)
897 {var td=document.createElement("td");var label=document.createElement("label");var input=document.createElement("input");input.type="checkbox";input.state=state;input.addEventListener("click",clickListener.bind(this),false);inputs.push(input);label.appendChild(input);label.appendChild(document.createTextNode(":"+state));td.appendChild(label);return td;}
898 var tr=table.createChild("tr");tr.appendChild(createCheckbox.call(this,"active"));tr.appendChild(createCheckbox.call(this,"hover"));tr=table.createChild("tr");tr.appendChild(createCheckbox.call(this,"focus"));tr.appendChild(createCheckbox.call(this,"visited"));this._elementStatePane.appendChild(table);},filterRegex:function()
899 {return this._filterRegex;},_createPropertyFilterElement:function(isComputedStyleFilter,filterCallback)
900 {var input=document.createElement("input");input.type="text";input.placeholder=isComputedStyleFilter?WebInspector.UIString("Filter"):WebInspector.UIString("Find in Styles");var boundSearchHandler=searchHandler.bind(this);function searchHandler()
901 {var regex=input.value?new RegExp(input.value.escapeForRegExp(),"i"):null;filterCallback(regex);input.parentNode.classList.toggle("styles-filter-engaged",!!input.value);this._updateFilter(isComputedStyleFilter);}
902 input.addEventListener("input",boundSearchHandler,false);function keydownHandler(event)
903 {var Esc="U+001B";if(event.keyIdentifier!==Esc||!input.value)
904 return;event.consume(true);input.value="";boundSearchHandler();}
905 input.addEventListener("keydown",keydownHandler,false);return input;},_updateFilter:function(isComputedStyleFilter)
906 {for(var pseudoId in this.sections){var sections=this.sections[pseudoId];for(var i=0;i<sections.length;++i){var section=sections[i];if(isComputedStyleFilter!==!!section.computedStyle)
907 continue;section._updateFilter();}}},_showUserAgentStylesSettingChanged:function(event)
908 {var showStyles=(event.data);this.element.classList.toggle("show-user-styles",showStyles);},willHide:function()
909 {this._spectrumHelper.hide();this._discardElementUnderMouse();},_discardElementUnderMouse:function()
910 {if(this._elementUnderMouse)
911 this._elementUnderMouse.classList.remove("styles-panel-hovered");delete this._elementUnderMouse;},_mouseMovedOverElement:function(e)
912 {if(this._elementUnderMouse&&e.target!==this._elementUnderMouse)
913 this._discardElementUnderMouse();this._elementUnderMouse=e.target;if(WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(e))
914 this._elementUnderMouse.classList.add("styles-panel-hovered");},_keyDown:function(e)
915 {if((!WebInspector.isMac()&&e.keyCode===WebInspector.KeyboardShortcut.Keys.Ctrl.code)||(WebInspector.isMac()&&e.keyCode===WebInspector.KeyboardShortcut.Keys.Meta.code)){if(this._elementUnderMouse)
916 this._elementUnderMouse.classList.add("styles-panel-hovered");}},_keyUp:function(e)
917 {if((!WebInspector.isMac()&&e.keyCode===WebInspector.KeyboardShortcut.Keys.Ctrl.code)||(WebInspector.isMac()&&e.keyCode===WebInspector.KeyboardShortcut.Keys.Meta.code)){this._discardElementUnderMouse();}},__proto__:WebInspector.SidebarPane.prototype}
918 WebInspector.ComputedStyleSidebarPane=function()
919 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Computed Style"));}
920 WebInspector.ComputedStyleSidebarPane.prototype={setHostingPane:function(pane)
921 {this._stylesSidebarPane=pane;},setFilterBoxContainer:function(element)
922 {element.appendChild(this._stylesSidebarPane._createPropertyFilterElement(true,filterCallback.bind(this)));function filterCallback(regex)
923 {this._filterRegex=regex;}},wasShown:function()
924 {WebInspector.SidebarPane.prototype.wasShown.call(this);if(!this._hasFreshContent)
925 this.prepareContent();},prepareContent:function(callback)
926 {function wrappedCallback(){this._hasFreshContent=true;if(callback)
927 callback();delete this._hasFreshContent;}
928 this._stylesSidebarPane._refreshUpdate(null,true,wrappedCallback.bind(this));},filterRegex:function()
929 {return this._filterRegex;},__proto__:WebInspector.SidebarPane.prototype}
930 WebInspector.StylePropertiesSection=function(parentPane,styleRule,editable,isInherited)
931 {WebInspector.PropertiesSection.call(this,"");this._parentPane=parentPane;this.styleRule=styleRule;this.rule=this.styleRule.rule;this.editable=editable;this.isInherited=isInherited;var extraClasses=(this.rule&&(this.rule.isUser||this.rule.isUserAgent)?" user-rule":"");this.element.className="styles-section matched-styles monospace"+extraClasses;this.propertiesElement.classList.remove("properties-tree");if(styleRule.media){for(var i=styleRule.media.length-1;i>=0;--i){var media=styleRule.media[i];var mediaDataElement=this.titleElement.createChild("div","media");var mediaText;switch(media.source){case WebInspector.CSSMedia.Source.LINKED_SHEET:case WebInspector.CSSMedia.Source.INLINE_SHEET:mediaText="media=\""+media.text+"\"";break;case WebInspector.CSSMedia.Source.MEDIA_RULE:mediaText="@media "+media.text;break;case WebInspector.CSSMedia.Source.IMPORT_RULE:mediaText="@import "+media.text;break;}
932 if(media.sourceURL){var refElement=mediaDataElement.createChild("div","subtitle");var rawLocation;var mediaHeader;if(media.range){mediaHeader=media.header();if(mediaHeader){var lineNumber=media.lineNumberInSource();var columnNumber=media.columnNumberInSource();console.assert(typeof lineNumber!=="undefined"&&typeof columnNumber!=="undefined");rawLocation=new WebInspector.CSSLocation(media.sourceURL,lineNumber,columnNumber);}}
933 var anchor;if(rawLocation)
934 anchor=this._parentPane._linkifier.linkifyCSSLocation(mediaHeader.id,rawLocation);else{anchor=WebInspector.linkifyResourceAsNode(media.sourceURL,undefined,"subtitle",media.sourceURL);}
935 anchor.style.float="right";refElement.appendChild(anchor);}
936 var mediaTextElement=mediaDataElement.createChild("span");mediaTextElement.textContent=mediaText;mediaTextElement.title=media.text;}}
937 var selectorContainer=document.createElement("div");this._selectorElement=document.createElement("span");this._selectorElement.textContent=styleRule.selectorText;selectorContainer.appendChild(this._selectorElement);var openBrace=document.createElement("span");openBrace.textContent=" {";selectorContainer.appendChild(openBrace);selectorContainer.addEventListener("mousedown",this._handleEmptySpaceMouseDown.bind(this),false);selectorContainer.addEventListener("click",this._handleSelectorContainerClick.bind(this),false);var closeBrace=document.createElement("div");closeBrace.textContent="}";this.element.appendChild(closeBrace);this._selectorElement.addEventListener("click",this._handleSelectorClick.bind(this),false);this.element.addEventListener("mousedown",this._handleEmptySpaceMouseDown.bind(this),false);this.element.addEventListener("click",this._handleEmptySpaceClick.bind(this),false);if(this.rule){if(this.rule.isUserAgent||this.rule.isUser)
938 this.editable=false;else{if(this.rule.id)
939 this.navigable=!!this.rule.resourceURL();}
940 this.titleElement.classList.add("styles-selector");}
941 this._usedProperties=styleRule.usedProperties;this._selectorRefElement=document.createElement("div");this._selectorRefElement.className="subtitle";this._updateRuleOrigin();selectorContainer.insertBefore(this._selectorRefElement,selectorContainer.firstChild);this.titleElement.appendChild(selectorContainer);this._selectorContainer=selectorContainer;if(isInherited)
942 this.element.classList.add("styles-show-inherited");if(this.navigable)
943 this.element.classList.add("navigable");if(!this.editable)
944 this.element.classList.add("read-only");}
945 WebInspector.StylePropertiesSection.prototype={get pane()
946 {return this._parentPane;},collapse:function()
947 {},handleClick:function()
948 {},isPropertyInherited:function(propertyName)
949 {if(this.isInherited){return!WebInspector.CSSMetadata.isPropertyInherited(propertyName);}
950 return false;},isPropertyOverloaded:function(propertyName,isShorthand)
951 {if(!this._usedProperties||this.noAffect)
952 return false;if(this.isInherited&&!WebInspector.CSSMetadata.isPropertyInherited(propertyName)){return false;}
953 var canonicalName=WebInspector.CSSMetadata.canonicalPropertyName(propertyName);var used=(canonicalName in this._usedProperties);if(used||!isShorthand)
954 return!used;var longhandProperties=this.styleRule.style.longhandProperties(propertyName);for(var j=0;j<longhandProperties.length;++j){var individualProperty=longhandProperties[j];if(WebInspector.CSSMetadata.canonicalPropertyName(individualProperty.name)in this._usedProperties)
955 return false;}
956 return true;},nextEditableSibling:function()
957 {var curSection=this;do{curSection=curSection.nextSibling;}while(curSection&&!curSection.editable);if(!curSection){curSection=this.firstSibling;while(curSection&&!curSection.editable)
958 curSection=curSection.nextSibling;}
959 return(curSection&&curSection.editable)?curSection:null;},previousEditableSibling:function()
960 {var curSection=this;do{curSection=curSection.previousSibling;}while(curSection&&!curSection.editable);if(!curSection){curSection=this.lastSibling;while(curSection&&!curSection.editable)
961 curSection=curSection.previousSibling;}
962 return(curSection&&curSection.editable)?curSection:null;},update:function(full)
963 {if(this.styleRule.selectorText)
964 this._selectorElement.textContent=this.styleRule.selectorText;this._markSelectorMatches();if(full){this.propertiesTreeOutline.removeChildren();this.populated=false;}else{var child=this.propertiesTreeOutline.children[0];while(child){child.overloaded=this.isPropertyOverloaded(child.name,child.isShorthand);child=child.traverseNextTreeElement(false,null,true);}}
965 this.afterUpdate();},afterUpdate:function()
966 {if(this._afterUpdate){this._afterUpdate(this);delete this._afterUpdate;}},onpopulate:function()
967 {var style=this.styleRule.style;var allProperties=style.allProperties;this.uniqueProperties=[];var styleHasEditableSource=this.editable&&!!style.range;if(styleHasEditableSource){for(var i=0;i<allProperties.length;++i){var property=allProperties[i];this.uniqueProperties.push(property);if(property.styleBased)
968 continue;var isShorthand=!!WebInspector.CSSMetadata.cssPropertiesMetainfo.longhands(property.name);var inherited=this.isPropertyInherited(property.name);var overloaded=property.inactive||this.isPropertyOverloaded(property.name);var item=new WebInspector.StylePropertyTreeElement(this._parentPane,this.styleRule,style,property,isShorthand,inherited,overloaded);this.propertiesTreeOutline.appendChild(item);}
969 return;}
970 var generatedShorthands={};for(var i=0;i<allProperties.length;++i){var property=allProperties[i];this.uniqueProperties.push(property);var isShorthand=!!WebInspector.CSSMetadata.cssPropertiesMetainfo.longhands(property.name);var shorthands=isShorthand?null:WebInspector.CSSMetadata.cssPropertiesMetainfo.shorthands(property.name);var shorthandPropertyAvailable=false;for(var j=0;shorthands&&!shorthandPropertyAvailable&&j<shorthands.length;++j){var shorthand=shorthands[j];if(shorthand in generatedShorthands){shorthandPropertyAvailable=true;continue;}
971 if(style.getLiveProperty(shorthand)){shorthandPropertyAvailable=true;continue;}
972 if(!style.shorthandValue(shorthand)){shorthandPropertyAvailable=false;continue;}
973 var shorthandProperty=new WebInspector.CSSProperty(style,style.allProperties.length,shorthand,style.shorthandValue(shorthand),false,false,true,true);var overloaded=property.inactive||this.isPropertyOverloaded(property.name,true);var item=new WebInspector.StylePropertyTreeElement(this._parentPane,this.styleRule,style,shorthandProperty,true,false,overloaded);this.propertiesTreeOutline.appendChild(item);generatedShorthands[shorthand]=shorthandProperty;shorthandPropertyAvailable=true;}
974 if(shorthandPropertyAvailable)
975 continue;var inherited=this.isPropertyInherited(property.name);var overloaded=property.inactive||this.isPropertyOverloaded(property.name,isShorthand);var item=new WebInspector.StylePropertyTreeElement(this._parentPane,this.styleRule,style,property,isShorthand,inherited,overloaded);this.propertiesTreeOutline.appendChild(item);}},_updateFilter:function()
976 {if(this.styleRule.isAttribute)
977 return;var regex=this._parentPane.filterRegex();var hideRule=regex&&!regex.test(this.element.textContent);this.element.classList.toggle("hidden",hideRule);if(hideRule)
978 return;var children=this.propertiesTreeOutline.children;for(var i=0;i<children.length;++i)
979 children[i]._updateFilter();if(this.styleRule.rule)
980 this._markSelectorHighlights();},_markSelectorMatches:function()
981 {var rule=this.styleRule.rule;if(!rule)
982 return;var matchingSelectors=rule.matchingSelectors;if(this.noAffect||matchingSelectors)
983 this._selectorElement.className="selector";if(!matchingSelectors)
984 return;var selectors=rule.selectors;var fragment=document.createDocumentFragment();var currentMatch=0;for(var i=0;i<selectors.length;++i){if(i)
985 fragment.appendChild(document.createTextNode(", "));var isSelectorMatching=matchingSelectors[currentMatch]===i;if(isSelectorMatching)
986 ++currentMatch;var rawLocation=new WebInspector.CSSLocation(rule.sourceURL,rule.lineNumberInSource(i),rule.columnNumberInSource(i));var matchingSelectorClass=isSelectorMatching?" selector-matches":"";var selectorElement=document.createElement("span");selectorElement.className="simple-selector"+matchingSelectorClass;if(rule.id)
987 selectorElement._selectorIndex=i;selectorElement.textContent=selectors[i].value;fragment.appendChild(selectorElement);}
988 this._selectorElement.removeChildren();this._selectorElement.appendChild(fragment);this._markSelectorHighlights();},_markSelectorHighlights:function()
989 {var selectors=this._selectorElement.getElementsByClassName("simple-selector");var regex=this.pane.filterRegex();for(var i=0;i<selectors.length;++i){var selectorMatchesFilter=regex&&regex.test(selectors[i].textContent);selectors[i].classList.toggle("filter-match",selectorMatchesFilter);}},_checkWillCancelEditing:function()
990 {var willCauseCancelEditing=this._willCauseCancelEditing;delete this._willCauseCancelEditing;return willCauseCancelEditing;},_handleSelectorContainerClick:function(event)
991 {if(this._checkWillCancelEditing()||!this.editable)
992 return;if(event.target===this._selectorContainer)
993 this.addNewBlankProperty(0).startEditing();},addNewBlankProperty:function(index)
994 {var style=this.styleRule.style;var property=style.newBlankProperty(index);var item=new WebInspector.StylePropertyTreeElement(this._parentPane,this.styleRule,style,property,false,false,false);index=property.index;this.propertiesTreeOutline.insertChild(item,index);item.listItemElement.textContent="";item._newProperty=true;item.updateTitle();return item;},_createRuleOriginNode:function()
995 {function linkifyUncopyable(url,line)
996 {var link=WebInspector.linkifyResourceAsNode(url,line,"",url+":"+(line+1));link.classList.add("webkit-html-resource-link");link.setAttribute("data-uncopyable",link.textContent);link.textContent="";return link;}
997 if(this.styleRule.sourceURL){var firstMatchingIndex=this.styleRule.rule.matchingSelectors&&this.rule.matchingSelectors.length?this.rule.matchingSelectors[0]:0;var matchingSelectorLocation=new WebInspector.CSSLocation(this.styleRule.sourceURL,this.rule.lineNumberInSource(firstMatchingIndex),this.rule.columnNumberInSource(firstMatchingIndex));return this._parentPane._linkifier.linkifyCSSLocation(this.rule.id.styleSheetId,matchingSelectorLocation)||linkifyUncopyable(this.styleRule.sourceURL,this.rule.lineNumberInSource());}
998 if(!this.rule)
999 return document.createTextNode("");if(this.rule.isUserAgent)
1000 return document.createTextNode(WebInspector.UIString("user agent stylesheet"));if(this.rule.isUser)
1001 return document.createTextNode(WebInspector.UIString("user stylesheet"));if(this.rule.isViaInspector)
1002 return document.createTextNode(WebInspector.UIString("via inspector"));return document.createTextNode("");},_handleEmptySpaceMouseDown:function()
1003 {this._willCauseCancelEditing=this._parentPane._isEditingStyle;},_handleEmptySpaceClick:function(event)
1004 {if(!this.editable)
1005 return;if(!window.getSelection().isCollapsed)
1006 return;if(this._checkWillCancelEditing())
1007 return;if(event.target.classList.contains("header")||this.element.classList.contains("read-only")||event.target.enclosingNodeOrSelfWithClass("media")){event.consume();return;}
1008 this.expand();this.addNewBlankProperty().startEditing();},_handleSelectorClick:function(event)
1009 {if(WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)&&this.navigable&&event.target.classList.contains("simple-selector")){var index=event.target._selectorIndex;var styleSheetHeader=WebInspector.cssModel.styleSheetHeaderForId(this.rule.id.styleSheetId);var uiLocation=styleSheetHeader.rawLocationToUILocation(this.rule.lineNumberInSource(index),this.rule.columnNumberInSource(index));WebInspector.Revealer.reveal(uiLocation);return;}
1010 this._startEditingOnMouseEvent();event.consume(true);},_startEditingOnMouseEvent:function()
1011 {if(!this.editable)
1012 return;if(!this.rule&&this.propertiesTreeOutline.children.length===0){this.expand();this.addNewBlankProperty().startEditing();return;}
1013 if(!this.rule)
1014 return;this.startEditingSelector();},startEditingSelector:function()
1015 {var element=this._selectorElement;if(WebInspector.isBeingEdited(element))
1016 return;element.scrollIntoViewIfNeeded(false);element.textContent=element.textContent;var config=new WebInspector.InplaceEditor.Config(this.editingSelectorCommitted.bind(this),this.editingSelectorCancelled.bind(this));WebInspector.InplaceEditor.startEditing(this._selectorElement,config);window.getSelection().setBaseAndExtent(element,0,element,1);this._parentPane._isEditingStyle=true;},_moveEditorFromSelector:function(moveDirection)
1017 {this._markSelectorMatches();if(!moveDirection)
1018 return;if(moveDirection==="forward"){this.expand();var firstChild=this.propertiesTreeOutline.children[0];while(firstChild&&firstChild.inherited)
1019 firstChild=firstChild.nextSibling;if(!firstChild)
1020 this.addNewBlankProperty().startEditing();else
1021 firstChild.startEditing(firstChild.nameElement);}else{var previousSection=this.previousEditableSibling();if(!previousSection)
1022 return;previousSection.expand();previousSection.addNewBlankProperty().startEditing();}},editingSelectorCommitted:function(element,newContent,oldContent,context,moveDirection)
1023 {this._editingSelectorEnded();if(newContent)
1024 newContent=newContent.trim();if(newContent===oldContent){this._selectorElement.textContent=newContent;this._moveEditorFromSelector(moveDirection);return;}
1025 var selectedNode=this._parentPane.node;function successCallback(newRule)
1026 {var doesAffectSelectedNode=newRule.matchingSelectors.length>0;if(!doesAffectSelectedNode){this.noAffect=true;this.element.classList.add("no-affect");}else{delete this.noAffect;this.element.classList.remove("no-affect");}
1027 this.rule=newRule;this.styleRule={section:this,style:newRule.style,selectorText:newRule.selectorText,media:newRule.media,sourceURL:newRule.resourceURL(),rule:newRule};this._parentPane.update(selectedNode);this._updateRuleOrigin();finishOperationAndMoveEditor.call(this,moveDirection);}
1028 function finishOperationAndMoveEditor(direction)
1029 {delete this._parentPane._userOperation;this._moveEditorFromSelector(direction);}
1030 this._parentPane._userOperation=true;WebInspector.cssModel.setRuleSelector(this.rule.id,selectedNode?selectedNode.id:0,newContent,successCallback.bind(this),finishOperationAndMoveEditor.bind(this,moveDirection));},_updateRuleOrigin:function()
1031 {this._selectorRefElement.removeChildren();this._selectorRefElement.appendChild(this._createRuleOriginNode());},_editingSelectorEnded:function()
1032 {delete this._parentPane._isEditingStyle;},editingSelectorCancelled:function()
1033 {this._editingSelectorEnded();this._markSelectorMatches();},__proto__:WebInspector.PropertiesSection.prototype}
1034 WebInspector.ComputedStylePropertiesSection=function(stylesPane,styleRule,usedProperties)
1035 {WebInspector.PropertiesSection.call(this,"");var subtitle=this.headerElement.createChild("div","sidebar-pane-subtitle vbox");var showInheritedCheckbox=new WebInspector.Checkbox(WebInspector.UIString("Show inherited properties"),"hbox");subtitle.appendChild(showInheritedCheckbox.element);this._hasFreshContent=false;function showInheritedToggleFunction()
1036 {var showInherited=showInheritedCheckbox.checked;WebInspector.settings.showInheritedComputedStyleProperties.set(showInherited);if(showInherited)
1037 this.element.classList.add("styles-show-inherited");else
1038 this.element.classList.remove("styles-show-inherited");}
1039 showInheritedCheckbox.addEventListener(showInheritedToggleFunction.bind(this));this.element.className="styles-section monospace read-only computed-style";if(WebInspector.settings.showInheritedComputedStyleProperties.get()){this.element.classList.add("styles-show-inherited");showInheritedCheckbox.checked=true;}
1040 this._stylesPane=stylesPane;this.styleRule=styleRule;this._usedProperties=usedProperties;this._alwaysShowComputedProperties={"display":true,"height":true,"width":true};this.computedStyle=true;this._propertyTreeElements={};this._expandedPropertyNames={};}
1041 WebInspector.ComputedStylePropertiesSection.prototype={collapse:function(dontRememberState)
1042 {},_isPropertyInherited:function(propertyName)
1043 {var canonicalName=WebInspector.CSSMetadata.canonicalPropertyName(propertyName);return!(canonicalName in this._usedProperties)&&!(canonicalName in this._alwaysShowComputedProperties);},update:function()
1044 {this._expandedPropertyNames={};for(var name in this._propertyTreeElements){if(this._propertyTreeElements[name].expanded)
1045 this._expandedPropertyNames[name]=true;}
1046 this._propertyTreeElements={};this.propertiesTreeOutline.removeChildren();this.populated=false;},_updateFilter:function()
1047 {var children=this.propertiesTreeOutline.children;for(var i=0;i<children.length;++i)
1048 children[i]._updateFilter();},onpopulate:function()
1049 {function sorter(a,b)
1050 {return a.name.compareTo(b.name);}
1051 var style=this.styleRule.style;if(!style)
1052 return;var uniqueProperties=[];var allProperties=style.allProperties;for(var i=0;i<allProperties.length;++i)
1053 uniqueProperties.push(allProperties[i]);uniqueProperties.sort(sorter);this._propertyTreeElements={};for(var i=0;i<uniqueProperties.length;++i){var property=uniqueProperties[i];var inherited=this._isPropertyInherited(property.name);var item=new WebInspector.ComputedStylePropertyTreeElement(this._stylesPane,this.styleRule,style,property,inherited);this.propertiesTreeOutline.appendChild(item);this._propertyTreeElements[property.name]=item;}},rebuildComputedTrace:function(sections)
1054 {for(var i=0;i<sections.length;++i){var section=sections[i];if(section.computedStyle||section.isBlank)
1055 continue;for(var j=0;j<section.uniqueProperties.length;++j){var property=section.uniqueProperties[j];if(property.disabled)
1056 continue;if(section.isInherited&&!WebInspector.CSSMetadata.isPropertyInherited(property.name))
1057 continue;var treeElement=this._propertyTreeElements[property.name.toLowerCase()];if(treeElement){var fragment=document.createDocumentFragment();var selector=fragment.createChild("span");selector.style.color="gray";selector.textContent=section.styleRule.selectorText;fragment.appendChild(document.createTextNode(" - "+property.value+" "));var subtitle=fragment.createChild("span");subtitle.style.float="right";subtitle.appendChild(section._createRuleOriginNode());var childElement=new TreeElement(fragment,null,false);treeElement.appendChild(childElement);if(property.inactive||section.isPropertyOverloaded(property.name))
1058 childElement.listItemElement.classList.add("overloaded");if(!property.parsedOk){childElement.listItemElement.classList.add("not-parsed-ok");childElement.listItemElement.insertBefore(WebInspector.StylesSidebarPane.createExclamationMark(property),childElement.listItemElement.firstChild);if(WebInspector.StylesSidebarPane._ignoreErrorsForProperty(property))
1059 childElement.listItemElement.classList.add("has-ignorable-error");}}}}
1060 for(var name in this._expandedPropertyNames){if(name in this._propertyTreeElements)
1061 this._propertyTreeElements[name].expand();}},__proto__:WebInspector.PropertiesSection.prototype}
1062 WebInspector.BlankStylePropertiesSection=function(stylesPane,defaultSelectorText)
1063 {WebInspector.StylePropertiesSection.call(this,stylesPane,{selectorText:defaultSelectorText,rule:{isViaInspector:true}},true,false);this.element.classList.add("blank-section");}
1064 WebInspector.BlankStylePropertiesSection.prototype={get isBlank()
1065 {return!this._normal;},expand:function()
1066 {if(!this.isBlank)
1067 WebInspector.StylePropertiesSection.prototype.expand.call(this);},editingSelectorCommitted:function(element,newContent,oldContent,context,moveDirection)
1068 {if(!this.isBlank){WebInspector.StylePropertiesSection.prototype.editingSelectorCommitted.call(this,element,newContent,oldContent,context,moveDirection);return;}
1069 function successCallback(newRule)
1070 {var doesSelectorAffectSelectedNode=newRule.matchingSelectors.length>0;var styleRule={section:this,style:newRule.style,selectorText:newRule.selectorText,sourceURL:newRule.resourceURL(),rule:newRule};this.makeNormal(styleRule);if(!doesSelectorAffectSelectedNode){this.noAffect=true;this.element.classList.add("no-affect");}
1071 this._updateRuleOrigin();this.expand();if(this.element.parentElement)
1072 this._moveEditorFromSelector(moveDirection);delete this._parentPane._userOperation;this._editingSelectorEnded();this._markSelectorMatches();}
1073 if(newContent)
1074 newContent=newContent.trim();this._parentPane._userOperation=true;WebInspector.cssModel.requestViaInspectorStylesheet(this.pane.node,viaInspectorCallback.bind(this));function viaInspectorCallback(styleSheetHeader)
1075 {if(!styleSheetHeader){this.editingSelectorCancelled();return;}
1076 WebInspector.cssModel.addRule(styleSheetHeader.id,this.pane.node,newContent,successCallback.bind(this),this.editingSelectorCancelled.bind(this));}},editingSelectorCancelled:function()
1077 {delete this._parentPane._userOperation;if(!this.isBlank){WebInspector.StylePropertiesSection.prototype.editingSelectorCancelled.call(this);return;}
1078 this._editingSelectorEnded();this.pane.removeSection(this);},makeNormal:function(styleRule)
1079 {this.element.classList.remove("blank-section");this.styleRule=styleRule;this.rule=styleRule.rule;this._normal=true;},__proto__:WebInspector.StylePropertiesSection.prototype}
1080 WebInspector.StylePropertyTreeElementBase=function(styleRule,style,property,inherited,overloaded,hasChildren)
1081 {this._styleRule=styleRule;this.style=style;this.property=property;this._inherited=inherited;this._overloaded=overloaded;TreeElement.call(this,"",null,hasChildren);this.selectable=false;}
1082 WebInspector.StylePropertyTreeElementBase.prototype={node:function()
1083 {return null;},editablePane:function()
1084 {return null;},parentPane:function()
1085 {throw"Not implemented";},get inherited()
1086 {return this._inherited;},hasIgnorableError:function()
1087 {return!this.parsedOk&&WebInspector.StylesSidebarPane._ignoreErrorsForProperty(this.property);},set inherited(x)
1088 {if(x===this._inherited)
1089 return;this._inherited=x;this.updateState();},get overloaded()
1090 {return this._overloaded;},set overloaded(x)
1091 {if(x===this._overloaded)
1092 return;this._overloaded=x;this.updateState();},get disabled()
1093 {return this.property.disabled;},get name()
1094 {if(!this.disabled||!this.property.text)
1095 return this.property.name;var text=this.property.text;var index=text.indexOf(":");if(index<1)
1096 return this.property.name;text=text.substring(0,index).trim();if(text.startsWith("/*"))
1097 text=text.substring(2).trim();return text;},get value()
1098 {if(!this.disabled||!this.property.text)
1099 return this.property.value;var match=this.property.text.match(/(.*);\s*/);if(!match||!match[1])
1100 return this.property.value;var text=match[1];var index=text.indexOf(":");if(index<1)
1101 return this.property.value;return text.substring(index+1).trim();},get parsedOk()
1102 {return this.property.parsedOk;},onattach:function()
1103 {this.updateTitle();},updateTitle:function()
1104 {var value=this.value;this.updateState();var nameElement=document.createElement("span");nameElement.className="webkit-css-property";nameElement.textContent=this.name;nameElement.title=this.property.propertyText;this.nameElement=nameElement;this._expandElement=document.createElement("span");this._expandElement.className="expand-element";var valueElement=document.createElement("span");valueElement.className="value";this.valueElement=valueElement;function processValue(regex,processor,nextProcessor,valueText)
1105 {var container=document.createDocumentFragment();var items=valueText.replace(regex,"\0$1\0").split("\0");for(var i=0;i<items.length;++i){if((i%2)===0){if(nextProcessor)
1106 container.appendChild(nextProcessor(items[i]));else
1107 container.appendChild(document.createTextNode(items[i]));}else{var processedNode=processor(items[i]);if(processedNode)
1108 container.appendChild(processedNode);}}
1109 return container;}
1110 function linkifyURL(url)
1111 {var hrefUrl=url;var match=hrefUrl.match(/['"]?([^'"]+)/);if(match)
1112 hrefUrl=match[1];var container=document.createDocumentFragment();container.appendChild(document.createTextNode("url("));if(this._styleRule.sourceURL)
1113 hrefUrl=WebInspector.ParsedURL.completeURL(this._styleRule.sourceURL,hrefUrl);else if(this.node())
1114 hrefUrl=this.node().resolveURL(hrefUrl);var hasResource=hrefUrl&&!!WebInspector.resourceForURL(hrefUrl);container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl||url,url,undefined,!hasResource));container.appendChild(document.createTextNode(")"));return container;}
1115 if(value){var colorProcessor=processValue.bind(null,WebInspector.StylesSidebarPane._colorRegex,this._processColor.bind(this,nameElement,valueElement),null);valueElement.appendChild(processValue(/url\(\s*([^)]+)\s*\)/g,linkifyURL.bind(this),WebInspector.CSSMetadata.isColorAwareProperty(this.name)&&this.parsedOk?colorProcessor:null,value));}
1116 this.listItemElement.removeChildren();nameElement.normalize();valueElement.normalize();if(!this.treeOutline)
1117 return;if(this.disabled)
1118 this.listItemElement.createChild("span","styles-clipboard-only").createTextChild("/* ");this.listItemElement.appendChild(nameElement);this.listItemElement.appendChild(document.createTextNode(": "));this.listItemElement.appendChild(this._expandElement);this.listItemElement.appendChild(valueElement);this.listItemElement.appendChild(document.createTextNode(";"));if(this.disabled)
1119 this.listItemElement.createChild("span","styles-clipboard-only").createTextChild(" */");if(!this.parsedOk){this.hasChildren=false;this.listItemElement.classList.add("not-parsed-ok");this.listItemElement.insertBefore(WebInspector.StylesSidebarPane.createExclamationMark(this.property),this.listItemElement.firstChild);}
1120 if(this.property.inactive)
1121 this.listItemElement.classList.add("inactive");this._updateFilter();},_updateFilter:function()
1122 {var regEx=this.parentPane().filterRegex();this.listItemElement.classList.toggle("filter-match",!!regEx&&(regEx.test(this.property.name)||regEx.test(this.property.value)));},_processColor:function(nameElement,valueElement,text)
1123 {var color=WebInspector.Color.parse(text);if(!color)
1124 return document.createTextNode(text);var format=WebInspector.StylesSidebarPane._colorFormat(color);var spectrumHelper=this.editablePane()&&this.editablePane()._spectrumHelper;var spectrum=spectrumHelper?spectrumHelper.spectrum():null;var isEditable=!!(this._styleRule&&this._styleRule.editable!==false);var colorSwatch=new WebInspector.ColorSwatch(!isEditable);colorSwatch.setColorString(text);colorSwatch.element.addEventListener("click",swatchClick.bind(this),false);var scrollerElement;var boundSpectrumChanged=spectrumChanged.bind(this);var boundSpectrumHidden=spectrumHidden.bind(this);function spectrumChanged(e)
1125 {var colorString=(e.data);spectrum.displayText=colorString;colorValueElement.textContent=colorString;colorSwatch.setColorString(colorString);this.applyStyleText(nameElement.textContent+": "+valueElement.textContent,false,false,false);}
1126 function spectrumHidden(event)
1127 {if(scrollerElement)
1128 scrollerElement.removeEventListener("scroll",repositionSpectrum,false);var commitEdit=event.data;var propertyText=!commitEdit&&this.originalPropertyText?this.originalPropertyText:(nameElement.textContent+": "+valueElement.textContent);this.applyStyleText(propertyText,true,true,false);spectrum.removeEventListener(WebInspector.Spectrum.Events.ColorChanged,boundSpectrumChanged);spectrumHelper.removeEventListener(WebInspector.SpectrumPopupHelper.Events.Hidden,boundSpectrumHidden);delete this.editablePane()._isEditingStyle;delete this.originalPropertyText;}
1129 function repositionSpectrum()
1130 {spectrumHelper.reposition(colorSwatch.element);}
1131 function swatchClick(e)
1132 {e.consume(true);if(!spectrumHelper||e.shiftKey){changeColorDisplay();return;}
1133 if(!isEditable)
1134 return;var visible=spectrumHelper.toggle(colorSwatch.element,color,format);if(visible){spectrum.displayText=color.toString(format);this.originalPropertyText=this.property.propertyText;this.editablePane()._isEditingStyle=true;spectrum.addEventListener(WebInspector.Spectrum.Events.ColorChanged,boundSpectrumChanged);spectrumHelper.addEventListener(WebInspector.SpectrumPopupHelper.Events.Hidden,boundSpectrumHidden);scrollerElement=colorSwatch.element.enclosingNodeOrSelfWithClass("scroll-target");if(scrollerElement)
1135 scrollerElement.addEventListener("scroll",repositionSpectrum,false);else
1136 console.error("Unable to handle color picker scrolling");}}
1137 var colorValueElement=document.createElement("span");colorValueElement.textContent=color.toString(format);function nextFormat(curFormat)
1138 {var cf=WebInspector.Color.Format;switch(curFormat){case cf.Original:return!color.hasAlpha()?cf.RGB:cf.RGBA;case cf.RGB:case cf.RGBA:return!color.hasAlpha()?cf.HSL:cf.HSLA;case cf.HSL:case cf.HSLA:if(color.nickname())
1139 return cf.Nickname;if(!color.hasAlpha())
1140 return color.canBeShortHex()?cf.ShortHEX:cf.HEX;else
1141 return cf.Original;case cf.ShortHEX:return cf.HEX;case cf.HEX:return cf.Original;case cf.Nickname:if(!color.hasAlpha())
1142 return color.canBeShortHex()?cf.ShortHEX:cf.HEX;else
1143 return cf.Original;default:return cf.RGBA;}}
1144 function changeColorDisplay()
1145 {do{format=nextFormat(format);var currentValue=color.toString(format);}while(currentValue===colorValueElement.textContent);colorValueElement.textContent=currentValue;}
1146 var container=document.createElement("nobr");container.appendChild(colorSwatch.element);container.appendChild(colorValueElement);return container;},updateState:function()
1147 {if(!this.listItemElement)
1148 return;if(this.style.isPropertyImplicit(this.name))
1149 this.listItemElement.classList.add("implicit");else
1150 this.listItemElement.classList.remove("implicit");if(this.hasIgnorableError())
1151 this.listItemElement.classList.add("has-ignorable-error");else
1152 this.listItemElement.classList.remove("has-ignorable-error");if(this.inherited)
1153 this.listItemElement.classList.add("inherited");else
1154 this.listItemElement.classList.remove("inherited");if(this.overloaded)
1155 this.listItemElement.classList.add("overloaded");else
1156 this.listItemElement.classList.remove("overloaded");if(this.disabled)
1157 this.listItemElement.classList.add("disabled");else
1158 this.listItemElement.classList.remove("disabled");},__proto__:TreeElement.prototype}
1159 WebInspector.ComputedStylePropertyTreeElement=function(stylesPane,styleRule,style,property,inherited)
1160 {WebInspector.StylePropertyTreeElementBase.call(this,styleRule,style,property,inherited,false,false);this._stylesPane=stylesPane;}
1161 WebInspector.ComputedStylePropertyTreeElement.prototype={node:function()
1162 {return this._stylesPane.node;},editablePane:function()
1163 {return null;},parentPane:function()
1164 {return this._stylesPane._computedStylePane;},_updateFilter:function()
1165 {var regEx=this.parentPane().filterRegex();this.listItemElement.classList.toggle("hidden",!!regEx&&(!regEx.test(this.property.name)&&!regEx.test(this.property.value)));},__proto__:WebInspector.StylePropertyTreeElementBase.prototype}
1166 WebInspector.StylePropertyTreeElement=function(stylesPane,styleRule,style,property,isShorthand,inherited,overloaded)
1167 {WebInspector.StylePropertyTreeElementBase.call(this,styleRule,style,property,inherited,overloaded,isShorthand);this._parentPane=stylesPane;this.isShorthand=isShorthand;}
1168 WebInspector.StylePropertyTreeElement.prototype={node:function()
1169 {return this._parentPane.node;},editablePane:function()
1170 {return this._parentPane;},parentPane:function()
1171 {return this._parentPane;},section:function()
1172 {return this.treeOutline&&this.treeOutline.section;},_updatePane:function(userCallback)
1173 {var section=this.section();if(section&&section.pane)
1174 section.pane._refreshUpdate(section,false,userCallback);else{if(userCallback)
1175 userCallback();}},toggleEnabled:function(event)
1176 {var disabled=!event.target.checked;function callback(newStyle)
1177 {delete this._parentPane._userOperation;if(!newStyle)
1178 return;newStyle.parentRule=this.style.parentRule;this.style=newStyle;this._styleRule.style=newStyle;var section=this.section();if(section&&section.pane)
1179 section.pane.dispatchEventToListeners("style property toggled");this._updatePane();}
1180 this._parentPane._userOperation=true;this.property.setDisabled(disabled,callback.bind(this));event.consume();},onpopulate:function()
1181 {if(this.children.length||!this.isShorthand)
1182 return;var longhandProperties=this.style.longhandProperties(this.name);for(var i=0;i<longhandProperties.length;++i){var name=longhandProperties[i].name;var inherited=false;var overloaded=false;var section=this.section();if(section){inherited=section.isPropertyInherited(name);overloaded=section.isPropertyOverloaded(name);}
1183 var liveProperty=this.style.getLiveProperty(name);if(!liveProperty)
1184 continue;var item=new WebInspector.StylePropertyTreeElement(this._parentPane,this._styleRule,this.style,liveProperty,false,inherited,overloaded);this.appendChild(item);}},onattach:function()
1185 {WebInspector.StylePropertyTreeElementBase.prototype.onattach.call(this);this.listItemElement.addEventListener("mousedown",this._mouseDown.bind(this));this.listItemElement.addEventListener("mouseup",this._resetMouseDownElement.bind(this));this.listItemElement.addEventListener("click",this._mouseClick.bind(this));},_mouseDown:function(event)
1186 {if(this._parentPane){this._parentPane._mouseDownTreeElement=this;this._parentPane._mouseDownTreeElementIsName=this._isNameElement(event.target);this._parentPane._mouseDownTreeElementIsValue=this._isValueElement(event.target);}},_resetMouseDownElement:function()
1187 {if(this._parentPane){delete this._parentPane._mouseDownTreeElement;delete this._parentPane._mouseDownTreeElementIsName;delete this._parentPane._mouseDownTreeElementIsValue;}},updateTitle:function()
1188 {WebInspector.StylePropertyTreeElementBase.prototype.updateTitle.call(this);if(this.parsedOk&&this.section()&&this.parent.root){var enabledCheckboxElement=document.createElement("input");enabledCheckboxElement.className="enabled-button";enabledCheckboxElement.type="checkbox";enabledCheckboxElement.checked=!this.disabled;enabledCheckboxElement.addEventListener("click",this.toggleEnabled.bind(this),false);this.listItemElement.insertBefore(enabledCheckboxElement,this.listItemElement.firstChild);}},_mouseClick:function(event)
1189 {if(!window.getSelection().isCollapsed)
1190 return;event.consume(true);if(event.target===this.listItemElement){var section=this.section();if(!section||!section.editable)
1191 return;if(section._checkWillCancelEditing())
1192 return;section.addNewBlankProperty(this.property.index+1).startEditing();return;}
1193 if(WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)&&this.section().navigable){this._navigateToSource(event.target);return;}
1194 this.startEditing(event.target);},_navigateToSource:function(element)
1195 {console.assert(this.section().navigable);var propertyNameClicked=element===this.nameElement;WebInspector.Revealer.reveal(this.property.uiLocation(propertyNameClicked));},_isNameElement:function(element)
1196 {return element.enclosingNodeOrSelfWithClass("webkit-css-property")===this.nameElement;},_isValueElement:function(element)
1197 {return!!element.enclosingNodeOrSelfWithClass("value");},startEditing:function(selectElement)
1198 {if(this.parent.isShorthand)
1199 return;if(selectElement===this._expandElement)
1200 return;var section=this.section();if(section&&!section.editable)
1201 return;if(!selectElement)
1202 selectElement=this.nameElement;else
1203 selectElement=selectElement.enclosingNodeOrSelfWithClass("webkit-css-property")||selectElement.enclosingNodeOrSelfWithClass("value");if(WebInspector.isBeingEdited(selectElement))
1204 return;var isEditingName=selectElement===this.nameElement;if(!isEditingName)
1205 this.valueElement.textContent=restoreURLs(this.valueElement.textContent,this.value);function restoreURLs(fieldValue,modelValue)
1206 {const urlRegex=/\b(url\([^)]*\))/g;var splitFieldValue=fieldValue.split(urlRegex);if(splitFieldValue.length===1)
1207 return fieldValue;var modelUrlRegex=new RegExp(urlRegex);for(var i=1;i<splitFieldValue.length;i+=2){var match=modelUrlRegex.exec(modelValue);if(match)
1208 splitFieldValue[i]=match[0];}
1209 return splitFieldValue.join("");}
1210 var context={expanded:this.expanded,hasChildren:this.hasChildren,isEditingName:isEditingName,previousContent:selectElement.textContent};this.hasChildren=false;if(selectElement.parentElement)
1211 selectElement.parentElement.classList.add("child-editing");selectElement.textContent=selectElement.textContent;function pasteHandler(context,event)
1212 {var data=event.clipboardData.getData("Text");if(!data)
1213 return;var colonIdx=data.indexOf(":");if(colonIdx<0)
1214 return;var name=data.substring(0,colonIdx).trim();var value=data.substring(colonIdx+1).trim();event.preventDefault();if(!("originalName"in context)){context.originalName=this.nameElement.textContent;context.originalValue=this.valueElement.textContent;}
1215 this.property.name=name;this.property.value=value;this.nameElement.textContent=name;this.valueElement.textContent=value;this.nameElement.normalize();this.valueElement.normalize();this.editingCommitted(event.target.textContent,context,"forward");}
1216 function blurListener(context,event)
1217 {var treeElement=this._parentPane._mouseDownTreeElement;var moveDirection="";if(treeElement===this){if(isEditingName&&this._parentPane._mouseDownTreeElementIsValue)
1218 moveDirection="forward";if(!isEditingName&&this._parentPane._mouseDownTreeElementIsName)
1219 moveDirection="backward";}
1220 this.editingCommitted(event.target.textContent,context,moveDirection);}
1221 delete this.originalPropertyText;this._parentPane._isEditingStyle=true;if(selectElement.parentElement)
1222 selectElement.parentElement.scrollIntoViewIfNeeded(false);var applyItemCallback=!isEditingName?this._applyFreeFlowStyleTextEdit.bind(this,true):undefined;this._prompt=new WebInspector.StylesSidebarPane.CSSPropertyPrompt(isEditingName?WebInspector.CSSMetadata.cssPropertiesMetainfo:WebInspector.CSSMetadata.keywordsForProperty(this.nameElement.textContent),this,isEditingName);if(applyItemCallback){this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemApplied,applyItemCallback,this);this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemAccepted,applyItemCallback,this);}
1223 var proxyElement=this._prompt.attachAndStartEditing(selectElement,blurListener.bind(this,context));proxyElement.addEventListener("keydown",this.editingNameValueKeyDown.bind(this,context),false);proxyElement.addEventListener("keypress",this.editingNameValueKeyPress.bind(this,context),false);if(isEditingName)
1224 proxyElement.addEventListener("paste",pasteHandler.bind(this,context),false);window.getSelection().setBaseAndExtent(selectElement,0,selectElement,1);},editingNameValueKeyDown:function(context,event)
1225 {if(event.handled)
1226 return;var isEditingName=context.isEditingName;var result;if(isEnterKey(event)){event.preventDefault();result="forward";}else if(event.keyCode===WebInspector.KeyboardShortcut.Keys.Esc.code||event.keyIdentifier==="U+001B")
1227 result="cancel";else if(!isEditingName&&this._newProperty&&event.keyCode===WebInspector.KeyboardShortcut.Keys.Backspace.code){var selection=window.getSelection();if(selection.isCollapsed&&!selection.focusOffset){event.preventDefault();result="backward";}}else if(event.keyIdentifier==="U+0009"){result=event.shiftKey?"backward":"forward";event.preventDefault();}
1228 if(result){switch(result){case"cancel":this.editingCancelled(null,context);break;case"forward":case"backward":this.editingCommitted(event.target.textContent,context,result);break;}
1229 event.consume();return;}
1230 if(!isEditingName)
1231 this._applyFreeFlowStyleTextEdit(false);},editingNameValueKeyPress:function(context,event)
1232 {function shouldCommitValueSemicolon(text,cursorPosition)
1233 {var openQuote="";for(var i=0;i<cursorPosition;++i){var ch=text[i];if(ch==="\\"&&openQuote!=="")
1234 ++i;else if(!openQuote&&(ch==="\""||ch==="'"))
1235 openQuote=ch;else if(openQuote===ch)
1236 openQuote="";}
1237 return!openQuote;}
1238 var keyChar=String.fromCharCode(event.charCode);var isFieldInputTerminated=(context.isEditingName?keyChar===":":keyChar===";"&&shouldCommitValueSemicolon(event.target.textContent,event.target.selectionLeftOffset()));if(isFieldInputTerminated){event.consume(true);this.editingCommitted(event.target.textContent,context,"forward");return;}},_applyFreeFlowStyleTextEdit:function(now)
1239 {if(this._applyFreeFlowStyleTextEditTimer)
1240 clearTimeout(this._applyFreeFlowStyleTextEditTimer);function apply()
1241 {var valueText=this.valueElement.textContent;if(valueText.indexOf(";")===-1)
1242 this.applyStyleText(this.nameElement.textContent+": "+valueText,false,false,false);}
1243 if(now)
1244 apply.call(this);else
1245 this._applyFreeFlowStyleTextEditTimer=setTimeout(apply.bind(this),100);},kickFreeFlowStyleEditForTest:function()
1246 {this._applyFreeFlowStyleTextEdit(true);},editingEnded:function(context)
1247 {this._resetMouseDownElement();if(this._applyFreeFlowStyleTextEditTimer)
1248 clearTimeout(this._applyFreeFlowStyleTextEditTimer);this.hasChildren=context.hasChildren;if(context.expanded)
1249 this.expand();var editedElement=context.isEditingName?this.nameElement:this.valueElement;if(editedElement.parentElement)
1250 editedElement.parentElement.classList.remove("child-editing");delete this._parentPane._isEditingStyle;},editingCancelled:function(element,context)
1251 {this._removePrompt();this._revertStyleUponEditingCanceled(this.originalPropertyText);this.editingEnded(context);},_revertStyleUponEditingCanceled:function(originalPropertyText)
1252 {if(typeof originalPropertyText==="string"){delete this.originalPropertyText;this.applyStyleText(originalPropertyText,true,false,true);}else{if(this._newProperty)
1253 this.treeOutline.removeChild(this);else
1254 this.updateTitle();}},_findSibling:function(moveDirection)
1255 {var target=this;do{target=(moveDirection==="forward"?target.nextSibling:target.previousSibling);}while(target&&target.inherited);return target;},editingCommitted:function(userInput,context,moveDirection)
1256 {this._removePrompt();this.editingEnded(context);var isEditingName=context.isEditingName;var createNewProperty,moveToPropertyName,moveToSelector;var isDataPasted="originalName"in context;var isDirtyViaPaste=isDataPasted&&(this.nameElement.textContent!==context.originalName||this.valueElement.textContent!==context.originalValue);var isPropertySplitPaste=isDataPasted&&isEditingName&&this.valueElement.textContent!==context.originalValue;var moveTo=this;var moveToOther=(isEditingName^(moveDirection==="forward"));var abandonNewProperty=this._newProperty&&!userInput&&(moveToOther||isEditingName);if(moveDirection==="forward"&&(!isEditingName||isPropertySplitPaste)||moveDirection==="backward"&&isEditingName){moveTo=moveTo._findSibling(moveDirection);if(moveTo)
1257 moveToPropertyName=moveTo.name;else if(moveDirection==="forward"&&(!this._newProperty||userInput))
1258 createNewProperty=true;else if(moveDirection==="backward")
1259 moveToSelector=true;}
1260 var moveToIndex=moveTo&&this.treeOutline?this.treeOutline.children.indexOf(moveTo):-1;var blankInput=/^\s*$/.test(userInput);var shouldCommitNewProperty=this._newProperty&&(isPropertySplitPaste||moveToOther||(!moveDirection&&!isEditingName)||(isEditingName&&blankInput));var section=this.section();if(((userInput!==context.previousContent||isDirtyViaPaste)&&!this._newProperty)||shouldCommitNewProperty){section._afterUpdate=moveToNextCallback.bind(this,this._newProperty,!blankInput,section);var propertyText;if(blankInput||(this._newProperty&&/^\s*$/.test(this.valueElement.textContent)))
1261 propertyText="";else{if(isEditingName)
1262 propertyText=userInput+": "+this.property.value;else
1263 propertyText=this.property.name+": "+userInput;}
1264 this.applyStyleText(propertyText,true,true,false);}else{if(isEditingName)
1265 this.property.name=userInput;else
1266 this.property.value=userInput;if(!isDataPasted&&!this._newProperty)
1267 this.updateTitle();moveToNextCallback.call(this,this._newProperty,false,section);}
1268 function moveToNextCallback(alreadyNew,valueChanged,section)
1269 {if(!moveDirection)
1270 return;if(moveTo&&moveTo.parent){moveTo.startEditing(!isEditingName?moveTo.nameElement:moveTo.valueElement);return;}
1271 if(moveTo&&!moveTo.parent){var propertyElements=section.propertiesTreeOutline.children;if(moveDirection==="forward"&&blankInput&&!isEditingName)
1272 --moveToIndex;if(moveToIndex>=propertyElements.length&&!this._newProperty)
1273 createNewProperty=true;else{var treeElement=moveToIndex>=0?propertyElements[moveToIndex]:null;if(treeElement){var elementToEdit=!isEditingName||isPropertySplitPaste?treeElement.nameElement:treeElement.valueElement;if(alreadyNew&&blankInput)
1274 elementToEdit=moveDirection==="forward"?treeElement.nameElement:treeElement.valueElement;treeElement.startEditing(elementToEdit);return;}else if(!alreadyNew)
1275 moveToSelector=true;}}
1276 if(createNewProperty){if(alreadyNew&&!valueChanged&&(isEditingName^(moveDirection==="backward")))
1277 return;section.addNewBlankProperty().startEditing();return;}
1278 if(abandonNewProperty){moveTo=this._findSibling(moveDirection);var sectionToEdit=(moveTo||moveDirection==="backward")?section:section.nextEditableSibling();if(sectionToEdit){if(sectionToEdit.rule)
1279 sectionToEdit.startEditingSelector();else
1280 sectionToEdit._moveEditorFromSelector(moveDirection);}
1281 return;}
1282 if(moveToSelector){if(section.rule)
1283 section.startEditingSelector();else
1284 section._moveEditorFromSelector(moveDirection);}}},_removePrompt:function()
1285 {if(this._prompt){this._prompt.detach();delete this._prompt;}},_hasBeenModifiedIncrementally:function()
1286 {return typeof this.originalPropertyText==="string"||(!!this.property.propertyText&&this._newProperty);},applyStyleText:function(styleText,updateInterface,majorChange,isRevert)
1287 {function userOperationFinishedCallback(parentPane,updateInterface)
1288 {if(updateInterface)
1289 delete parentPane._userOperation;}
1290 if(!isRevert&&!updateInterface&&!this._hasBeenModifiedIncrementally()){this.originalPropertyText=this.property.propertyText;}
1291 if(!this.treeOutline)
1292 return;var section=this.section();styleText=styleText.replace(/\s/g," ").trim();var styleTextLength=styleText.length;if(!styleTextLength&&updateInterface&&!isRevert&&this._newProperty&&!this._hasBeenModifiedIncrementally()){this.parent.removeChild(this);section.afterUpdate();return;}
1293 var currentNode=this._parentPane.node;if(updateInterface)
1294 this._parentPane._userOperation=true;function callback(userCallback,originalPropertyText,newStyle)
1295 {if(!newStyle){if(updateInterface){this._revertStyleUponEditingCanceled(originalPropertyText);}
1296 userCallback();return;}
1297 if(this._newProperty)
1298 this._newPropertyInStyle=true;newStyle.parentRule=this.style.parentRule;this.style=newStyle;this.property=newStyle.propertyAt(this.property.index);this._styleRule.style=this.style;if(section&&section.pane)
1299 section.pane.dispatchEventToListeners("style edited");if(updateInterface&&currentNode===this.node()){this._updatePane(userCallback);return;}
1300 userCallback();}
1301 if(styleText.length&&!/;\s*$/.test(styleText))
1302 styleText+=";";var overwriteProperty=!!(!this._newProperty||this._newPropertyInStyle);this.property.setText(styleText,majorChange,overwriteProperty,callback.bind(this,userOperationFinishedCallback.bind(null,this._parentPane,updateInterface),this.originalPropertyText));},ondblclick:function()
1303 {return true;},isEventWithinDisclosureTriangle:function(event)
1304 {return event.target===this._expandElement;},__proto__:WebInspector.StylePropertyTreeElementBase.prototype}
1305 WebInspector.StylesSidebarPane.CSSPropertyPrompt=function(cssCompletions,sidebarPane,isEditingName)
1306 {WebInspector.TextPrompt.call(this,this._buildPropertyCompletions.bind(this),WebInspector.StyleValueDelimiters);this.setSuggestBoxEnabled("generic-suggest");this._cssCompletions=cssCompletions;this._sidebarPane=sidebarPane;this._isEditingName=isEditingName;if(!isEditingName)
1307 this.disableDefaultSuggestionForEmptyInput();}
1308 WebInspector.StylesSidebarPane.CSSPropertyPrompt.prototype={onKeyDown:function(event)
1309 {switch(event.keyIdentifier){case"Up":case"Down":case"PageUp":case"PageDown":if(this._handleNameOrValueUpDown(event)){event.preventDefault();return true;}
1310 break;case"Enter":if(this.autoCompleteElement&&!this.autoCompleteElement.textContent.length){this.tabKeyPressed();return true;}
1311 break;}
1312 return WebInspector.TextPrompt.prototype.onKeyDown.call(this,event);},onMouseWheel:function(event)
1313 {if(this._handleNameOrValueUpDown(event)){event.consume(true);return;}
1314 WebInspector.TextPrompt.prototype.onMouseWheel.call(this,event);},tabKeyPressed:function()
1315 {this.acceptAutoComplete();return false;},_handleNameOrValueUpDown:function(event)
1316 {function finishHandler(originalValue,replacementString)
1317 {this._sidebarPane.applyStyleText(this._sidebarPane.nameElement.textContent+": "+this._sidebarPane.valueElement.textContent,false,false,false);}
1318 if(!this._isEditingName&&WebInspector.handleElementValueModifications(event,this._sidebarPane.valueElement,finishHandler.bind(this),this._isValueSuggestion.bind(this)))
1319 return true;return false;},_isValueSuggestion:function(word)
1320 {if(!word)
1321 return false;word=word.toLowerCase();return this._cssCompletions.keySet().hasOwnProperty(word);},_buildPropertyCompletions:function(proxyElement,wordRange,force,completionsReadyCallback)
1322 {var prefix=wordRange.toString().toLowerCase();if(!prefix&&!force&&(this._isEditingName||proxyElement.textContent.length)){completionsReadyCallback([]);return;}
1323 var results=this._cssCompletions.startsWith(prefix);var selectedIndex=this._cssCompletions.mostUsedOf(results);completionsReadyCallback(results,selectedIndex);},__proto__:WebInspector.TextPrompt.prototype};WebInspector.ElementsPanel=function()
1324 {WebInspector.Panel.call(this,"elements");this.registerRequiredCSS("breadcrumbList.css");this.registerRequiredCSS("elementsPanel.css");this.registerRequiredCSS("textPrompt.css");this.setHideOnDetach();this._splitView=new WebInspector.SplitView(true,true,"elementsPanelSplitViewState",325,325);this._splitView.addEventListener(WebInspector.SplitView.Events.SidebarSizeChanged,this._updateTreeOutlineVisibleWidth.bind(this));this._splitView.show(this.element);this._searchableView=new WebInspector.SearchableView(this);this._searchableView.setMinimumSize(25,19);this._searchableView.show(this._splitView.mainElement());var stackElement=this._searchableView.element;this.contentElement=stackElement.createChild("div");this.contentElement.id="elements-content";this.contentElement.classList.add("outline-disclosure");this.contentElement.classList.add("source-code");if(!WebInspector.settings.domWordWrap.get())
1325 this.contentElement.classList.add("nowrap");WebInspector.settings.domWordWrap.addChangeListener(this._domWordWrapSettingChanged.bind(this));this.contentElement.addEventListener("contextmenu",this._contextMenuEventFired.bind(this),true);this._splitView.sidebarElement().addEventListener("contextmenu",this._sidebarContextMenuEventFired.bind(this),false);this.treeOutline=new WebInspector.ElementsTreeOutline(true,true,this._populateContextMenu.bind(this),this._setPseudoClassForNodeId.bind(this));this.treeOutline.wireToDomAgent();this.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.SelectedNodeChanged,this._selectedNodeChanged,this);this.treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.ElementsTreeUpdated,this._updateBreadcrumbIfNeeded,this);var crumbsContainer=stackElement.createChild("div");crumbsContainer.id="elements-crumbs";this.crumbsElement=crumbsContainer.createChild("div","crumbs");this.crumbsElement.addEventListener("mousemove",this._mouseMovedInCrumbs.bind(this),false);this.crumbsElement.addEventListener("mouseout",this._mouseMovedOutOfCrumbs.bind(this),false);this.sidebarPanes={};this.sidebarPanes.platformFonts=new WebInspector.PlatformFontsSidebarPane();this.sidebarPanes.computedStyle=new WebInspector.ComputedStyleSidebarPane();this.sidebarPanes.styles=new WebInspector.StylesSidebarPane(this.sidebarPanes.computedStyle,this._setPseudoClassForNodeId.bind(this));this._matchedStylesFilterBoxContainer=document.createElement("div");this._matchedStylesFilterBoxContainer.className="sidebar-pane-filter-box";this._computedStylesFilterBoxContainer=document.createElement("div");this._computedStylesFilterBoxContainer.className="sidebar-pane-filter-box";this.sidebarPanes.styles.setFilterBoxContainers(this._matchedStylesFilterBoxContainer,this._computedStylesFilterBoxContainer);this.sidebarPanes.metrics=new WebInspector.MetricsSidebarPane();this.sidebarPanes.properties=new WebInspector.PropertiesSidebarPane();this.sidebarPanes.domBreakpoints=WebInspector.domBreakpointsSidebarPane.createProxy(this);this.sidebarPanes.eventListeners=new WebInspector.EventListenersSidebarPane();this.sidebarPanes.styles.addEventListener(WebInspector.SidebarPane.EventTypes.wasShown,this.updateStyles.bind(this,false));this.sidebarPanes.metrics.addEventListener(WebInspector.SidebarPane.EventTypes.wasShown,this.updateMetrics.bind(this));this.sidebarPanes.platformFonts.addEventListener(WebInspector.SidebarPane.EventTypes.wasShown,this.updatePlatformFonts.bind(this));this.sidebarPanes.properties.addEventListener(WebInspector.SidebarPane.EventTypes.wasShown,this.updateProperties.bind(this));this.sidebarPanes.eventListeners.addEventListener(WebInspector.SidebarPane.EventTypes.wasShown,this.updateEventListeners.bind(this));this.sidebarPanes.styles.addEventListener("style edited",this._stylesPaneEdited,this);this.sidebarPanes.styles.addEventListener("style property toggled",this._stylesPaneEdited,this);this.sidebarPanes.metrics.addEventListener("metrics edited",this._metricsPaneEdited,this);this._extensionSidebarPanes=[];WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged,this._dockSideChanged.bind(this));WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this));this._dockSideChanged();this._popoverHelper=new WebInspector.PopoverHelper(this.element,this._getPopoverAnchor.bind(this),this._showPopover.bind(this));this._popoverHelper.setTimeout(0);WebInspector.domModel.addEventListener(WebInspector.DOMModel.Events.DocumentUpdated,this._documentUpdatedEvent,this);WebInspector.settings.showUAShadowDOM.addChangeListener(this._showUAShadowDOMChanged.bind(this));WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.ModelWasEnabled,this._updateSidebars,this);}
1326 WebInspector.ElementsPanel.prototype={_updateTreeOutlineVisibleWidth:function()
1327 {if(!this.treeOutline)
1328 return;var width=this._splitView.element.offsetWidth;if(this._splitView.isVertical())
1329 width-=this._splitView.sidebarSize();this.treeOutline.setVisibleWidth(width);this.treeOutline.updateSelection();this.updateBreadcrumbSizes();},defaultFocusedElement:function()
1330 {return this.treeOutline.element;},searchableView:function()
1331 {return this._searchableView;},wasShown:function()
1332 {if(this.treeOutline.element.parentElement!==this.contentElement)
1333 this.contentElement.appendChild(this.treeOutline.element);WebInspector.Panel.prototype.wasShown.call(this);this.updateBreadcrumb();this.treeOutline.updateSelection();this.treeOutline.setVisible(true);if(!this.treeOutline.rootDOMNode)
1334 if(WebInspector.domModel.existingDocument())
1335 this._documentUpdated(WebInspector.domModel.existingDocument());else
1336 WebInspector.domModel.requestDocument();},willHide:function()
1337 {WebInspector.domModel.hideDOMNodeHighlight();this.treeOutline.setVisible(false);this._popoverHelper.hidePopover();this.contentElement.removeChild(this.treeOutline.element);WebInspector.Panel.prototype.willHide.call(this);},onResize:function()
1338 {this._updateTreeOutlineVisibleWidth();},omitDefaultSelection:function()
1339 {this._omitDefaultSelection=true;},stopOmittingDefaultSelection:function()
1340 {delete this._omitDefaultSelection;},_setPseudoClassForNodeId:function(nodeId,pseudoClass,enable)
1341 {var node=WebInspector.domModel.nodeForId(nodeId);if(!node)
1342 return;var pseudoClasses=node.getUserProperty(WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName);if(enable){pseudoClasses=pseudoClasses||[];if(pseudoClasses.indexOf(pseudoClass)>=0)
1343 return;pseudoClasses.push(pseudoClass);node.setUserProperty(WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName,pseudoClasses);}else{if(!pseudoClasses||pseudoClasses.indexOf(pseudoClass)<0)
1344 return;pseudoClasses.remove(pseudoClass);if(!pseudoClasses.length)
1345 node.removeUserProperty(WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName);}
1346 this.treeOutline.updateOpenCloseTags(node);WebInspector.cssModel.forcePseudoState(node.id,node.getUserProperty(WebInspector.ElementsTreeOutline.PseudoStateDecorator.PropertyName));this._metricsPaneEdited();this._stylesPaneEdited();WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.ForcedElementState,selector:WebInspector.DOMPresentationUtils.fullQualifiedSelector(node,false),enabled:enable,state:pseudoClass});},_selectedNodeChanged:function()
1347 {var selectedNode=this.selectedDOMNode();if(!selectedNode&&this._lastValidSelectedNode)
1348 this._selectedPathOnReset=this._lastValidSelectedNode.path();this.updateBreadcrumb(false);this._updateSidebars();if(selectedNode){ConsoleAgent.addInspectedNode(selectedNode.id);this._lastValidSelectedNode=selectedNode;}
1349 WebInspector.notifications.dispatchEventToListeners(WebInspector.NotificationService.Events.SelectedNodeChanged);},_updateSidebars:function()
1350 {for(var pane in this.sidebarPanes)
1351 this.sidebarPanes[pane].needsUpdate=true;this.updateStyles(true);this.updateMetrics();this.updatePlatformFonts();this.updateProperties();this.updateEventListeners();},_reset:function()
1352 {delete this.currentQuery;},_documentUpdatedEvent:function(event)
1353 {this._documentUpdated(event.data);},_documentUpdated:function(inspectedRootDocument)
1354 {this._reset();this.searchCanceled();this.treeOutline.rootDOMNode=inspectedRootDocument;if(!inspectedRootDocument){if(this.isShowing())
1355 WebInspector.domModel.requestDocument();return;}
1356 WebInspector.domBreakpointsSidebarPane.restoreBreakpoints();function selectNode(candidateFocusNode)
1357 {if(!candidateFocusNode)
1358 candidateFocusNode=inspectedRootDocument.body||inspectedRootDocument.documentElement;if(!candidateFocusNode)
1359 return;this.selectDOMNode(candidateFocusNode);if(this.treeOutline.selectedTreeElement)
1360 this.treeOutline.selectedTreeElement.expand();}
1361 function selectLastSelectedNode(nodeId)
1362 {if(this.selectedDOMNode()){return;}
1363 var node=nodeId?WebInspector.domModel.nodeForId(nodeId):null;selectNode.call(this,node);}
1364 if(this._omitDefaultSelection)
1365 return;if(this._selectedPathOnReset)
1366 WebInspector.domModel.pushNodeByPathToFrontend(this._selectedPathOnReset,selectLastSelectedNode.bind(this));else
1367 selectNode.call(this,null);delete this._selectedPathOnReset;},searchCanceled:function()
1368 {delete this._searchQuery;this._hideSearchHighlights();this._searchableView.updateSearchMatchesCount(0);delete this._currentSearchResultIndex;delete this._searchResults;WebInspector.domModel.cancelSearch();},performSearch:function(query,shouldJump)
1369 {this.searchCanceled();const whitespaceTrimmedQuery=query.trim();if(!whitespaceTrimmedQuery.length)
1370 return;this._searchQuery=query;function resultCountCallback(resultCount)
1371 {this._searchableView.updateSearchMatchesCount(resultCount);if(!resultCount)
1372 return;this._searchResults=new Array(resultCount);this._currentSearchResultIndex=-1;if(shouldJump)
1373 this.jumpToNextSearchResult();}
1374 WebInspector.domModel.performSearch(whitespaceTrimmedQuery,resultCountCallback.bind(this));},_contextMenuEventFired:function(event)
1375 {var contextMenu=new WebInspector.ContextMenu(event);this.treeOutline.populateContextMenu(contextMenu,event);contextMenu.show();},_domWordWrapSettingChanged:function(event)
1376 {if(event.data)
1377 this.contentElement.classList.remove("nowrap");else
1378 this.contentElement.classList.add("nowrap");var selectedNode=this.selectedDOMNode();if(!selectedNode)
1379 return;var treeElement=this.treeOutline.findTreeElement(selectedNode);if(treeElement)
1380 treeElement.updateSelection();},switchToAndFocus:function(node)
1381 {this._searchableView.cancelSearch();WebInspector.inspectorView.setCurrentPanel(this);this.selectDOMNode(node,true);},_populateContextMenu:function(contextMenu,node)
1382 {contextMenu.appendSeparator();var pane=WebInspector.domBreakpointsSidebarPane;pane.populateNodeContextMenu(node,contextMenu);},_getPopoverAnchor:function(element)
1383 {var anchor=element.enclosingNodeOrSelfWithClass("webkit-html-resource-link");if(anchor){if(!anchor.href)
1384 return null;var resource=WebInspector.resourceTreeModel.resourceForURL(anchor.href);if(!resource||resource.type!==WebInspector.resourceTypes.Image)
1385 return null;anchor.removeAttribute("title");}
1386 return anchor;},_loadDimensionsForNode:function(treeElement,callback)
1387 {if(treeElement.treeOutline!==this.treeOutline){callback();return;}
1388 var node=(treeElement.representedObject);if(!node.nodeName()||node.nodeName().toLowerCase()!=="img"){callback();return;}
1389 WebInspector.RemoteObject.resolveNode(node,"",resolvedNode);function resolvedNode(object)
1390 {if(!object){callback();return;}
1391 object.callFunctionJSON(dimensions,undefined,callback);object.release();function dimensions()
1392 {return{offsetWidth:this.offsetWidth,offsetHeight:this.offsetHeight,naturalWidth:this.naturalWidth,naturalHeight:this.naturalHeight};}}},_showPopover:function(anchor,popover)
1393 {var listItem=anchor.enclosingNodeOrSelfWithNodeName("li");if(listItem&&listItem.treeElement)
1394 this._loadDimensionsForNode(listItem.treeElement,WebInspector.DOMPresentationUtils.buildImagePreviewContents.bind(WebInspector.DOMPresentationUtils,anchor.href,true,showPopover));else
1395 WebInspector.DOMPresentationUtils.buildImagePreviewContents(anchor.href,true,showPopover);function showPopover(contents)
1396 {if(!contents)
1397 return;popover.setCanShrink(false);popover.show(contents,anchor);}},jumpToNextSearchResult:function()
1398 {if(!this._searchResults)
1399 return;this._hideSearchHighlights();if(++this._currentSearchResultIndex>=this._searchResults.length)
1400 this._currentSearchResultIndex=0;this._highlightCurrentSearchResult();},jumpToPreviousSearchResult:function()
1401 {if(!this._searchResults)
1402 return;this._hideSearchHighlights();if(--this._currentSearchResultIndex<0)
1403 this._currentSearchResultIndex=(this._searchResults.length-1);this._highlightCurrentSearchResult();},_highlightCurrentSearchResult:function()
1404 {var index=this._currentSearchResultIndex;var searchResults=this._searchResults;var searchResult=searchResults[index];if(searchResult===null){this._searchableView.updateCurrentMatchIndex(index);return;}
1405 function searchCallback(node)
1406 {searchResults[index]=node;this._highlightCurrentSearchResult();}
1407 if(typeof searchResult==="undefined"){WebInspector.domModel.searchResult(index,searchCallback.bind(this));return;}
1408 this._searchableView.updateCurrentMatchIndex(index);var treeElement=this.treeOutline.findTreeElement(searchResult);if(treeElement){treeElement.highlightSearchResults(this._searchQuery);treeElement.reveal();var matches=treeElement.listItemElement.getElementsByClassName("highlighted-search-result");if(matches.length)
1409 matches[0].scrollIntoViewIfNeeded();}},_hideSearchHighlights:function()
1410 {if(!this._searchResults)
1411 return;var searchResult=this._searchResults[this._currentSearchResultIndex];if(!searchResult)
1412 return;var treeElement=this.treeOutline.findTreeElement(searchResult);if(treeElement)
1413 treeElement.hideSearchHighlights();},selectedDOMNode:function()
1414 {return this.treeOutline.selectedDOMNode();},selectDOMNode:function(node,focus)
1415 {this.treeOutline.selectDOMNode(node,focus);},_updateBreadcrumbIfNeeded:function(event)
1416 {var nodes=(event.data||[]);if(!nodes.length)
1417 return;var crumbs=this.crumbsElement;for(var crumb=crumbs.firstChild;crumb;crumb=crumb.nextSibling){if(nodes.indexOf(crumb.representedObject)!==-1){this.updateBreadcrumb(true);return;}}},_stylesPaneEdited:function()
1418 {this.sidebarPanes.metrics.needsUpdate=true;this.updateMetrics();this.sidebarPanes.platformFonts.needsUpdate=true;this.updatePlatformFonts();},_metricsPaneEdited:function()
1419 {this.sidebarPanes.styles.needsUpdate=true;this.updateStyles(true);},_mouseMovedInCrumbs:function(event)
1420 {var nodeUnderMouse=document.elementFromPoint(event.pageX,event.pageY);var crumbElement=nodeUnderMouse.enclosingNodeOrSelfWithClass("crumb");WebInspector.domModel.highlightDOMNode(crumbElement?crumbElement.representedObject.id:0);if("_mouseOutOfCrumbsTimeout"in this){clearTimeout(this._mouseOutOfCrumbsTimeout);delete this._mouseOutOfCrumbsTimeout;}},_mouseMovedOutOfCrumbs:function(event)
1421 {var nodeUnderMouse=document.elementFromPoint(event.pageX,event.pageY);if(nodeUnderMouse&&nodeUnderMouse.isDescendant(this.crumbsElement))
1422 return;WebInspector.domModel.hideDOMNodeHighlight();this._mouseOutOfCrumbsTimeout=setTimeout(this.updateBreadcrumbSizes.bind(this),1000);},updateBreadcrumb:function(forceUpdate)
1423 {if(!this.isShowing())
1424 return;var crumbs=this.crumbsElement;var handled=false;var crumb=crumbs.firstChild;while(crumb){if(crumb.representedObject===this.selectedDOMNode()){crumb.classList.add("selected");handled=true;}else{crumb.classList.remove("selected");}
1425 crumb=crumb.nextSibling;}
1426 if(handled&&!forceUpdate){this.updateBreadcrumbSizes();return;}
1427 crumbs.removeChildren();var panel=this;function selectCrumbFunction(event)
1428 {var crumb=event.currentTarget;if(crumb.classList.contains("collapsed")){if(crumb===panel.crumbsElement.firstChild){var currentCrumb=crumb;while(currentCrumb){var hidden=currentCrumb.classList.contains("hidden");var collapsed=currentCrumb.classList.contains("collapsed");if(!hidden&&!collapsed)
1429 break;crumb=currentCrumb;currentCrumb=currentCrumb.nextSibling;}}
1430 panel.updateBreadcrumbSizes(crumb);}else
1431 panel.selectDOMNode(crumb.representedObject,true);event.preventDefault();}
1432 for(var current=this.selectedDOMNode();current;current=current.parentNode){if(current.nodeType()===Node.DOCUMENT_NODE)
1433 continue;crumb=document.createElement("span");crumb.className="crumb";crumb.representedObject=current;crumb.addEventListener("mousedown",selectCrumbFunction,false);var crumbTitle="";switch(current.nodeType()){case Node.ELEMENT_NODE:if(current.pseudoType())
1434 crumbTitle="::"+current.pseudoType();else
1435 WebInspector.DOMPresentationUtils.decorateNodeLabel(current,crumb);break;case Node.TEXT_NODE:crumbTitle=WebInspector.UIString("(text)");break;case Node.COMMENT_NODE:crumbTitle="<!-->";break;case Node.DOCUMENT_TYPE_NODE:crumbTitle="<!DOCTYPE>";break;case Node.DOCUMENT_FRAGMENT_NODE:crumbTitle=current.shadowRootType()?"#shadow-root":current.nodeNameInCorrectCase();break;default:crumbTitle=current.nodeNameInCorrectCase();}
1436 if(!crumb.childNodes.length){var nameElement=document.createElement("span");nameElement.textContent=crumbTitle;crumb.appendChild(nameElement);crumb.title=crumbTitle;}
1437 if(current===this.selectedDOMNode())
1438 crumb.classList.add("selected");crumbs.insertBefore(crumb,crumbs.firstChild);}
1439 this.updateBreadcrumbSizes();},updateBreadcrumbSizes:function(focusedCrumb)
1440 {if(!this.isShowing())
1441 return;var crumbs=this.crumbsElement;if(!crumbs.firstChild)
1442 return;var selectedIndex=0;var focusedIndex=0;var selectedCrumb;for(var i=0;i<crumbs.childNodes.length;++i){var crumb=crumbs.childNodes[i];if(!selectedCrumb&&crumb.classList.contains("selected")){selectedCrumb=crumb;selectedIndex=i;}
1443 if(crumb===focusedCrumb)
1444 focusedIndex=i;crumb.classList.remove("compact","collapsed","hidden");}
1445 var contentElementWidth=this.contentElement.offsetWidth;var normalSizes=[];for(var i=0;i<crumbs.childNodes.length;++i){var crumb=crumbs.childNodes[i];normalSizes[i]=crumb.offsetWidth;}
1446 var compactSizes=[];for(var i=0;i<crumbs.childNodes.length;++i){var crumb=crumbs.childNodes[i];crumb.classList.add("compact");}
1447 for(var i=0;i<crumbs.childNodes.length;++i){var crumb=crumbs.childNodes[i];compactSizes[i]=crumb.offsetWidth;}
1448 crumbs.firstChild.classList.add("collapsed");var collapsedSize=crumbs.firstChild.offsetWidth;for(var i=0;i<crumbs.childNodes.length;++i){var crumb=crumbs.childNodes[i];crumb.classList.remove("compact","collapsed");}
1449 function crumbsAreSmallerThanContainer()
1450 {var totalSize=0;for(var i=0;i<crumbs.childNodes.length;++i){var crumb=crumbs.childNodes[i];if(crumb.classList.contains("hidden"))
1451 continue;if(crumb.classList.contains("collapsed")){totalSize+=collapsedSize;continue;}
1452 totalSize+=crumb.classList.contains("compact")?compactSizes[i]:normalSizes[i];}
1453 const rightPadding=10;return totalSize+rightPadding<contentElementWidth;}
1454 if(crumbsAreSmallerThanContainer())
1455 return;var BothSides=0;var AncestorSide=-1;var ChildSide=1;function makeCrumbsSmaller(shrinkingFunction,direction)
1456 {var significantCrumb=focusedCrumb||selectedCrumb;var significantIndex=significantCrumb===selectedCrumb?selectedIndex:focusedIndex;function shrinkCrumbAtIndex(index)
1457 {var shrinkCrumb=crumbs.childNodes[index];if(shrinkCrumb&&shrinkCrumb!==significantCrumb)
1458 shrinkingFunction(shrinkCrumb);if(crumbsAreSmallerThanContainer())
1459 return true;return false;}
1460 if(direction){var index=(direction>0?0:crumbs.childNodes.length-1);while(index!==significantIndex){if(shrinkCrumbAtIndex(index))
1461 return true;index+=(direction>0?1:-1);}}else{var startIndex=0;var endIndex=crumbs.childNodes.length-1;while(startIndex!=significantIndex||endIndex!=significantIndex){var startDistance=significantIndex-startIndex;var endDistance=endIndex-significantIndex;if(startDistance>=endDistance)
1462 var index=startIndex++;else
1463 var index=endIndex--;if(shrinkCrumbAtIndex(index))
1464 return true;}}
1465 return false;}
1466 function coalesceCollapsedCrumbs()
1467 {var crumb=crumbs.firstChild;var collapsedRun=false;var newStartNeeded=false;var newEndNeeded=false;while(crumb){var hidden=crumb.classList.contains("hidden");if(!hidden){var collapsed=crumb.classList.contains("collapsed");if(collapsedRun&&collapsed){crumb.classList.add("hidden");crumb.classList.remove("compact");crumb.classList.remove("collapsed");if(crumb.classList.contains("start")){crumb.classList.remove("start");newStartNeeded=true;}
1468 if(crumb.classList.contains("end")){crumb.classList.remove("end");newEndNeeded=true;}
1469 continue;}
1470 collapsedRun=collapsed;if(newEndNeeded){newEndNeeded=false;crumb.classList.add("end");}}else
1471 collapsedRun=true;crumb=crumb.nextSibling;}
1472 if(newStartNeeded){crumb=crumbs.lastChild;while(crumb){if(!crumb.classList.contains("hidden")){crumb.classList.add("start");break;}
1473 crumb=crumb.previousSibling;}}}
1474 function compact(crumb)
1475 {if(crumb.classList.contains("hidden"))
1476 return;crumb.classList.add("compact");}
1477 function collapse(crumb,dontCoalesce)
1478 {if(crumb.classList.contains("hidden"))
1479 return;crumb.classList.add("collapsed");crumb.classList.remove("compact");if(!dontCoalesce)
1480 coalesceCollapsedCrumbs();}
1481 if(!focusedCrumb){if(makeCrumbsSmaller(compact,ChildSide))
1482 return;if(makeCrumbsSmaller(collapse,ChildSide))
1483 return;}
1484 if(makeCrumbsSmaller(compact,focusedCrumb?BothSides:AncestorSide))
1485 return;if(makeCrumbsSmaller(collapse,focusedCrumb?BothSides:AncestorSide))
1486 return;if(!selectedCrumb)
1487 return;compact(selectedCrumb);if(crumbsAreSmallerThanContainer())
1488 return;collapse(selectedCrumb,true);},updateStyles:function(forceUpdate)
1489 {if(!WebInspector.cssModel.isEnabled())
1490 return;var stylesSidebarPane=this.sidebarPanes.styles;var computedStylePane=this.sidebarPanes.computedStyle;if((!stylesSidebarPane.isShowing()&&!computedStylePane.isShowing())||!stylesSidebarPane.needsUpdate)
1491 return;stylesSidebarPane.update(this.selectedDOMNode(),forceUpdate);stylesSidebarPane.needsUpdate=false;},updateMetrics:function()
1492 {if(!WebInspector.cssModel.isEnabled())
1493 return;var metricsSidebarPane=this.sidebarPanes.metrics;if(!metricsSidebarPane.isShowing()||!metricsSidebarPane.needsUpdate)
1494 return;metricsSidebarPane.update(this.selectedDOMNode());metricsSidebarPane.needsUpdate=false;},updatePlatformFonts:function()
1495 {if(!WebInspector.cssModel.isEnabled())
1496 return;var platformFontsSidebar=this.sidebarPanes.platformFonts;if(!platformFontsSidebar.isShowing()||!platformFontsSidebar.needsUpdate)
1497 return;platformFontsSidebar.update(this.selectedDOMNode());platformFontsSidebar.needsUpdate=false;},updateProperties:function()
1498 {var propertiesSidebarPane=this.sidebarPanes.properties;if(!propertiesSidebarPane.isShowing()||!propertiesSidebarPane.needsUpdate)
1499 return;propertiesSidebarPane.update(this.selectedDOMNode());propertiesSidebarPane.needsUpdate=false;},updateEventListeners:function()
1500 {var eventListenersSidebarPane=this.sidebarPanes.eventListeners;if(!eventListenersSidebarPane.isShowing()||!eventListenersSidebarPane.needsUpdate)
1501 return;eventListenersSidebarPane.update(this.selectedDOMNode());eventListenersSidebarPane.needsUpdate=false;},handleShortcut:function(event)
1502 {function handleUndoRedo()
1503 {if(WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)&&!event.shiftKey&&event.keyIdentifier==="U+005A"){WebInspector.domModel.undo(this._updateSidebars.bind(this));event.handled=true;return;}
1504 var isRedoKey=WebInspector.isMac()?event.metaKey&&event.shiftKey&&event.keyIdentifier==="U+005A":event.ctrlKey&&event.keyIdentifier==="U+0059";if(isRedoKey){DOMAgent.redo(this._updateSidebars.bind(this));event.handled=true;}}
1505 if(!this.treeOutline.editing()){handleUndoRedo.call(this);if(event.handled)
1506 return;}
1507 this.treeOutline.handleShortcut(event);},handleCopyEvent:function(event)
1508 {var currentFocusElement=WebInspector.currentFocusElement();if(currentFocusElement&&WebInspector.isBeingEdited(currentFocusElement))
1509 return;if(!window.getSelection().isCollapsed)
1510 return;event.clipboardData.clearData();event.preventDefault();this.selectedDOMNode().copyNode();},_leaveUserAgentShadowDOM:function(node)
1511 {var userAgentShadowRoot=node.ancestorUserAgentShadowRoot();return userAgentShadowRoot?(userAgentShadowRoot.parentNode):node;},revealAndSelectNode:function(nodeId)
1512 {WebInspector.inspectorView.setCurrentPanel(this);var node=WebInspector.domModel.nodeForId(nodeId);if(!node)
1513 return;node=WebInspector.settings.showUAShadowDOM.get()?node:this._leaveUserAgentShadowDOM(node);WebInspector.domModel.highlightDOMNodeForTwoSeconds(nodeId);this.selectDOMNode(node,true);},appendApplicableItems:function(event,contextMenu,target)
1514 {function selectNode(nodeId)
1515 {if(nodeId)
1516 WebInspector.domModel.inspectElement(nodeId);}
1517 function revealElement(remoteObject)
1518 {remoteObject.pushNodeToFrontend(selectNode);}
1519 var commandCallback;if(target instanceof WebInspector.RemoteObject){var remoteObject=(target);if(remoteObject.subtype==="node")
1520 commandCallback=revealElement.bind(null,remoteObject);}else if(target instanceof WebInspector.DOMNode){var domNode=(target);if(domNode.id)
1521 commandCallback=WebInspector.domModel.inspectElement.bind(WebInspector.domModel,domNode.id);}
1522 if(!commandCallback)
1523 return;if(this.treeOutline.element.isAncestor(event.target))
1524 return;contextMenu.appendItem(WebInspector.useLowerCaseMenuTitles()?"Reveal in Elements panel":"Reveal in Elements Panel",commandCallback);},_sidebarContextMenuEventFired:function(event)
1525 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.show();},_dockSideChanged:function()
1526 {var vertically=WebInspector.dockController.isVertical()&&WebInspector.settings.splitVerticallyWhenDockedToRight.get();this._splitVertically(vertically);},_showUAShadowDOMChanged:function()
1527 {this.treeOutline.update();},_splitVertically:function(vertically)
1528 {if(this.sidebarPaneView&&vertically===!this._splitView.isVertical())
1529 return;if(this.sidebarPaneView){this.sidebarPaneView.detach();this._splitView.uninstallResizer(this.sidebarPaneView.headerElement());}
1530 this._splitView.setVertical(!vertically);var computedPane=new WebInspector.SidebarPane(WebInspector.UIString("Computed"));computedPane.element.classList.add("composite");computedPane.element.classList.add("fill");var expandComputed=computedPane.expand.bind(computedPane);computedPane.bodyElement.classList.add("metrics-and-computed");this.sidebarPanes.computedStyle.setExpandCallback(expandComputed);var matchedStylePanesWrapper=document.createElement("div");matchedStylePanesWrapper.className="style-panes-wrapper";var computedStylePanesWrapper=document.createElement("div");computedStylePanesWrapper.className="style-panes-wrapper";function showMetrics(inComputedStyle)
1531 {if(inComputedStyle)
1532 this.sidebarPanes.metrics.show(computedStylePanesWrapper,this.sidebarPanes.computedStyle.element);else
1533 this.sidebarPanes.metrics.show(matchedStylePanesWrapper);}
1534 function tabSelected(event)
1535 {var tabId=(event.data.tabId);if(tabId===computedPane.title())
1536 showMetrics.call(this,true);else if(tabId===stylesPane.title())
1537 showMetrics.call(this,false);}
1538 this.sidebarPaneView=new WebInspector.SidebarTabbedPane();if(vertically){this._splitView.installResizer(this.sidebarPaneView.headerElement());this.sidebarPanes.metrics.setExpandCallback(expandComputed);var compositePane=new WebInspector.SidebarPane(this.sidebarPanes.styles.title());compositePane.element.classList.add("composite");compositePane.element.classList.add("fill");var expandComposite=compositePane.expand.bind(compositePane);var splitView=new WebInspector.SplitView(true,true,"stylesPaneSplitViewState",0.5);splitView.show(compositePane.bodyElement);splitView.mainElement().appendChild(matchedStylePanesWrapper);splitView.sidebarElement().appendChild(computedStylePanesWrapper);this.sidebarPanes.styles.setExpandCallback(expandComposite);computedPane.show(computedStylePanesWrapper);computedPane.setExpandCallback(expandComposite);splitView.mainElement().appendChild(this._matchedStylesFilterBoxContainer);splitView.sidebarElement().appendChild(this._computedStylesFilterBoxContainer);this.sidebarPaneView.addPane(compositePane);}else{var stylesPane=new WebInspector.SidebarPane(this.sidebarPanes.styles.title());stylesPane.element.classList.add("composite");stylesPane.element.classList.add("fill");var expandStyles=stylesPane.expand.bind(stylesPane);stylesPane.bodyElement.classList.add("metrics-and-styles");stylesPane.bodyElement.appendChild(matchedStylePanesWrapper);computedPane.bodyElement.appendChild(computedStylePanesWrapper);this.sidebarPanes.styles.setExpandCallback(expandStyles);this.sidebarPanes.metrics.setExpandCallback(expandStyles);this.sidebarPaneView.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected,tabSelected,this);stylesPane.bodyElement.appendChild(this._matchedStylesFilterBoxContainer);computedPane.bodyElement.appendChild(this._computedStylesFilterBoxContainer);this.sidebarPaneView.addPane(stylesPane);this.sidebarPaneView.addPane(computedPane);}
1539 this.sidebarPanes.styles.show(matchedStylePanesWrapper);this.sidebarPanes.computedStyle.show(computedStylePanesWrapper);matchedStylePanesWrapper.appendChild(this.sidebarPanes.styles.titleElement);showMetrics.call(this,vertically);this.sidebarPanes.platformFonts.show(computedStylePanesWrapper);this.sidebarPaneView.addPane(this.sidebarPanes.eventListeners);this.sidebarPaneView.addPane(this.sidebarPanes.domBreakpoints);this.sidebarPaneView.addPane(this.sidebarPanes.properties);this._extensionSidebarPanesContainer=this.sidebarPaneView;for(var i=0;i<this._extensionSidebarPanes.length;++i)
1540 this._extensionSidebarPanesContainer.addPane(this._extensionSidebarPanes[i]);this.sidebarPaneView.show(this._splitView.sidebarElement());this.sidebarPanes.styles.expand();},addExtensionSidebarPane:function(id,pane)
1541 {this._extensionSidebarPanes.push(pane);this._extensionSidebarPanesContainer.addPane(pane);},__proto__:WebInspector.Panel.prototype}
1542 WebInspector.ElementsPanel.ContextMenuProvider=function()
1543 {}
1544 WebInspector.ElementsPanel.ContextMenuProvider.prototype={appendApplicableItems:function(event,contextMenu,target)
1545 {(WebInspector.inspectorView.panel("elements")).appendApplicableItems(event,contextMenu,target);}}
1546 WebInspector.ElementsPanel.DOMNodeRevealer=function()
1547 {}
1548 WebInspector.ElementsPanel.DOMNodeRevealer.prototype={reveal:function(node)
1549 {if(!(node instanceof WebInspector.DOMNode))
1550 return;if(WebInspector.inspectElementModeController&&WebInspector.inspectElementModeController.enabled()){InspectorFrontendHost.bringToFront();WebInspector.inspectElementModeController.disable();}
1551 (WebInspector.inspectorView.panel("elements")).revealAndSelectNode(node.id);}}