Upstream version 8.36.161.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / SourcesPanel.js
1 WebInspector.JavaScriptBreakpointsSidebarPane=function(breakpointManager,showSourceLineDelegate)
2 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Breakpoints"));this.registerRequiredCSS("breakpointsList.css");this._breakpointManager=breakpointManager;this._showSourceLineDelegate=showSourceLineDelegate;this.listElement=document.createElement("ol");this.listElement.className="breakpoint-list";this.emptyElement=document.createElement("div");this.emptyElement.className="info";this.emptyElement.textContent=WebInspector.UIString("No Breakpoints");this.bodyElement.appendChild(this.emptyElement);this._items=new Map();var breakpointLocations=this._breakpointManager.allBreakpointLocations();for(var i=0;i<breakpointLocations.length;++i)
3 this._addBreakpoint(breakpointLocations[i].breakpoint,breakpointLocations[i].uiLocation);this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded,this._breakpointAdded,this);this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved,this._breakpointRemoved,this);this.emptyElement.addEventListener("contextmenu",this._emptyElementContextMenu.bind(this),true);}
4 WebInspector.JavaScriptBreakpointsSidebarPane.prototype={_emptyElementContextMenu:function(event)
5 {var contextMenu=new WebInspector.ContextMenu(event);var breakpointActive=WebInspector.debuggerModel.breakpointsActive();var breakpointActiveTitle=breakpointActive?WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Deactivate breakpoints":"Deactivate Breakpoints"):WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Activate breakpoints":"Activate Breakpoints");contextMenu.appendItem(breakpointActiveTitle,WebInspector.debuggerModel.setBreakpointsActive.bind(WebInspector.debuggerModel,!breakpointActive));contextMenu.show();},_breakpointAdded:function(event)
6 {this._breakpointRemoved(event);var breakpoint=(event.data.breakpoint);var uiLocation=(event.data.uiLocation);this._addBreakpoint(breakpoint,uiLocation);},_addBreakpoint:function(breakpoint,uiLocation)
7 {var element=document.createElement("li");element.classList.add("cursor-pointer");element.addEventListener("contextmenu",this._breakpointContextMenu.bind(this,breakpoint),true);element.addEventListener("click",this._breakpointClicked.bind(this,uiLocation),false);var checkbox=document.createElement("input");checkbox.className="checkbox-elem";checkbox.type="checkbox";checkbox.checked=breakpoint.enabled();checkbox.addEventListener("click",this._breakpointCheckboxClicked.bind(this,breakpoint),false);element.appendChild(checkbox);var labelElement=document.createTextNode(uiLocation.linkText());element.appendChild(labelElement);var snippetElement=document.createElement("div");snippetElement.className="source-text monospace";element.appendChild(snippetElement);function didRequestContent(content)
8 {var lineEndings=content.lineEndings();if(uiLocation.lineNumber<lineEndings.length)
9 snippetElement.textContent=content.substring(lineEndings[uiLocation.lineNumber-1],lineEndings[uiLocation.lineNumber]);}
10 uiLocation.uiSourceCode.requestContent(didRequestContent.bind(this));element._data=uiLocation;var currentElement=this.listElement.firstChild;while(currentElement){if(currentElement._data&&this._compareBreakpoints(currentElement._data,element._data)>0)
11 break;currentElement=currentElement.nextSibling;}
12 this._addListElement(element,currentElement);var breakpointItem={};breakpointItem.element=element;breakpointItem.checkbox=checkbox;this._items.put(breakpoint,breakpointItem);this.expand();},_breakpointRemoved:function(event)
13 {var breakpoint=(event.data.breakpoint);var uiLocation=(event.data.uiLocation);var breakpointItem=this._items.get(breakpoint);if(!breakpointItem)
14 return;this._items.remove(breakpoint);this._removeListElement(breakpointItem.element);},highlightBreakpoint:function(breakpoint)
15 {var breakpointItem=this._items.get(breakpoint);if(!breakpointItem)
16 return;breakpointItem.element.classList.add("breakpoint-hit");this._highlightedBreakpointItem=breakpointItem;},clearBreakpointHighlight:function()
17 {if(this._highlightedBreakpointItem){this._highlightedBreakpointItem.element.classList.remove("breakpoint-hit");delete this._highlightedBreakpointItem;}},_breakpointClicked:function(uiLocation,event)
18 {this._showSourceLineDelegate(uiLocation.uiSourceCode,uiLocation.lineNumber);},_breakpointCheckboxClicked:function(breakpoint,event)
19 {event.consume();breakpoint.setEnabled(event.target.checked);},_breakpointContextMenu:function(breakpoint,event)
20 {var breakpoints=this._items.values();var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove breakpoint":"Remove Breakpoint"),breakpoint.remove.bind(breakpoint));if(breakpoints.length>1){var removeAllTitle=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove all breakpoints":"Remove All Breakpoints");contextMenu.appendItem(removeAllTitle,this._breakpointManager.removeAllBreakpoints.bind(this._breakpointManager));}
21 contextMenu.appendSeparator();var breakpointActive=WebInspector.debuggerModel.breakpointsActive();var breakpointActiveTitle=breakpointActive?WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Deactivate breakpoints":"Deactivate Breakpoints"):WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Activate breakpoints":"Activate Breakpoints");contextMenu.appendItem(breakpointActiveTitle,WebInspector.debuggerModel.setBreakpointsActive.bind(WebInspector.debuggerModel,!breakpointActive));function enabledBreakpointCount(breakpoints)
22 {var count=0;for(var i=0;i<breakpoints.length;++i){if(breakpoints[i].checkbox.checked)
23 count++;}
24 return count;}
25 if(breakpoints.length>1){var enableBreakpointCount=enabledBreakpointCount(breakpoints);var enableTitle=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Enable all breakpoints":"Enable All Breakpoints");var disableTitle=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Disable all breakpoints":"Disable All Breakpoints");contextMenu.appendSeparator();contextMenu.appendItem(enableTitle,this._breakpointManager.toggleAllBreakpoints.bind(this._breakpointManager,true),!(enableBreakpointCount!=breakpoints.length));contextMenu.appendItem(disableTitle,this._breakpointManager.toggleAllBreakpoints.bind(this._breakpointManager,false),!(enableBreakpointCount>1));}
26 contextMenu.show();},_addListElement:function(element,beforeElement)
27 {if(beforeElement)
28 this.listElement.insertBefore(element,beforeElement);else{if(!this.listElement.firstChild){this.bodyElement.removeChild(this.emptyElement);this.bodyElement.appendChild(this.listElement);}
29 this.listElement.appendChild(element);}},_removeListElement:function(element)
30 {this.listElement.removeChild(element);if(!this.listElement.firstChild){this.bodyElement.removeChild(this.listElement);this.bodyElement.appendChild(this.emptyElement);}},_compare:function(x,y)
31 {if(x!==y)
32 return x<y?-1:1;return 0;},_compareBreakpoints:function(b1,b2)
33 {return this._compare(b1.uiSourceCode.originURL(),b2.uiSourceCode.originURL())||this._compare(b1.lineNumber,b2.lineNumber);},reset:function()
34 {this.listElement.removeChildren();if(this.listElement.parentElement){this.bodyElement.removeChild(this.listElement);this.bodyElement.appendChild(this.emptyElement);}
35 this._items.clear();},__proto__:WebInspector.SidebarPane.prototype}
36 WebInspector.XHRBreakpointsSidebarPane=function()
37 {WebInspector.NativeBreakpointsSidebarPane.call(this,WebInspector.UIString("XHR Breakpoints"));this._breakpointElements={};var addButton=document.createElement("button");addButton.className="pane-title-button add";addButton.addEventListener("click",this._addButtonClicked.bind(this),false);addButton.title=WebInspector.UIString("Add XHR breakpoint");this.titleElement.appendChild(addButton);this.emptyElement.addEventListener("contextmenu",this._emptyElementContextMenu.bind(this),true);this._restoreBreakpoints();}
38 WebInspector.XHRBreakpointsSidebarPane.prototype={_emptyElementContextMenu:function(event)
39 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add breakpoint":"Add Breakpoint"),this._addButtonClicked.bind(this));contextMenu.show();},_addButtonClicked:function(event)
40 {if(event)
41 event.consume();this.expand();var inputElementContainer=document.createElement("p");inputElementContainer.className="breakpoint-condition";var inputElement=document.createElement("span");inputElementContainer.textContent=WebInspector.UIString("Break when URL contains:");inputElement.className="editing";inputElement.id="breakpoint-condition-input";inputElementContainer.appendChild(inputElement);this._addListElement(inputElementContainer,this.listElement.firstChild);function finishEditing(accept,e,text)
42 {this._removeListElement(inputElementContainer);if(accept){this._setBreakpoint(text,true);this._saveBreakpoints();}}
43 var config=new WebInspector.EditingConfig(finishEditing.bind(this,true),finishEditing.bind(this,false));WebInspector.startEditing(inputElement,config);},_setBreakpoint:function(url,enabled)
44 {if(url in this._breakpointElements)
45 return;var element=document.createElement("li");element._url=url;element.addEventListener("contextmenu",this._contextMenu.bind(this,url),true);var checkboxElement=document.createElement("input");checkboxElement.className="checkbox-elem";checkboxElement.type="checkbox";checkboxElement.checked=enabled;checkboxElement.addEventListener("click",this._checkboxClicked.bind(this,url),false);element._checkboxElement=checkboxElement;element.appendChild(checkboxElement);var labelElement=document.createElement("span");if(!url)
46 labelElement.textContent=WebInspector.UIString("Any XHR");else
47 labelElement.textContent=WebInspector.UIString("URL contains \"%s\"",url);labelElement.classList.add("cursor-auto");labelElement.addEventListener("dblclick",this._labelClicked.bind(this,url),false);element.appendChild(labelElement);var currentElement=this.listElement.firstChild;while(currentElement){if(currentElement._url&&currentElement._url<element._url)
48 break;currentElement=currentElement.nextSibling;}
49 this._addListElement(element,currentElement);this._breakpointElements[url]=element;if(enabled)
50 DOMDebuggerAgent.setXHRBreakpoint(url);},_removeBreakpoint:function(url)
51 {var element=this._breakpointElements[url];if(!element)
52 return;this._removeListElement(element);delete this._breakpointElements[url];if(element._checkboxElement.checked)
53 DOMDebuggerAgent.removeXHRBreakpoint(url);},_contextMenu:function(url,event)
54 {var contextMenu=new WebInspector.ContextMenu(event);function removeBreakpoint()
55 {this._removeBreakpoint(url);this._saveBreakpoints();}
56 function removeAllBreakpoints()
57 {for(var url in this._breakpointElements)
58 this._removeBreakpoint(url);this._saveBreakpoints();}
59 var removeAllTitle=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove all breakpoints":"Remove All Breakpoints");contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add breakpoint":"Add Breakpoint"),this._addButtonClicked.bind(this));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove breakpoint":"Remove Breakpoint"),removeBreakpoint.bind(this));contextMenu.appendItem(removeAllTitle,removeAllBreakpoints.bind(this));contextMenu.show();},_checkboxClicked:function(url,event)
60 {if(event.target.checked)
61 DOMDebuggerAgent.setXHRBreakpoint(url);else
62 DOMDebuggerAgent.removeXHRBreakpoint(url);this._saveBreakpoints();},_labelClicked:function(url)
63 {var element=this._breakpointElements[url];var inputElement=document.createElement("span");inputElement.className="breakpoint-condition editing";inputElement.textContent=url;this.listElement.insertBefore(inputElement,element);element.classList.add("hidden");function finishEditing(accept,e,text)
64 {this._removeListElement(inputElement);if(accept){this._removeBreakpoint(url);this._setBreakpoint(text,element._checkboxElement.checked);this._saveBreakpoints();}else
65 element.classList.remove("hidden");}
66 WebInspector.startEditing(inputElement,new WebInspector.EditingConfig(finishEditing.bind(this,true),finishEditing.bind(this,false)));},highlightBreakpoint:function(url)
67 {var element=this._breakpointElements[url];if(!element)
68 return;this.expand();element.classList.add("breakpoint-hit");this._highlightedElement=element;},clearBreakpointHighlight:function()
69 {if(this._highlightedElement){this._highlightedElement.classList.remove("breakpoint-hit");delete this._highlightedElement;}},_saveBreakpoints:function()
70 {var breakpoints=[];for(var url in this._breakpointElements)
71 breakpoints.push({url:url,enabled:this._breakpointElements[url]._checkboxElement.checked});WebInspector.settings.xhrBreakpoints.set(breakpoints);},_restoreBreakpoints:function()
72 {var breakpoints=WebInspector.settings.xhrBreakpoints.get();for(var i=0;i<breakpoints.length;++i){var breakpoint=breakpoints[i];if(breakpoint&&typeof breakpoint.url==="string")
73 this._setBreakpoint(breakpoint.url,breakpoint.enabled);}},__proto__:WebInspector.NativeBreakpointsSidebarPane.prototype}
74 WebInspector.EventListenerBreakpointsSidebarPane=function()
75 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Event Listener Breakpoints"));this.registerRequiredCSS("breakpointsList.css");this.categoriesElement=document.createElement("ol");this.categoriesElement.tabIndex=0;this.categoriesElement.classList.add("properties-tree");this.categoriesElement.classList.add("event-listener-breakpoints");this.categoriesTreeOutline=new TreeOutline(this.categoriesElement);this.bodyElement.appendChild(this.categoriesElement);this._breakpointItems={};this._createCategory(WebInspector.UIString("Animation"),false,["requestAnimationFrame","cancelAnimationFrame","animationFrameFired"]);this._createCategory(WebInspector.UIString("Control"),true,["resize","scroll","zoom","focus","blur","select","change","submit","reset"]);this._createCategory(WebInspector.UIString("Clipboard"),true,["copy","cut","paste","beforecopy","beforecut","beforepaste"]);this._createCategory(WebInspector.UIString("DOM Mutation"),true,["DOMActivate","DOMFocusIn","DOMFocusOut","DOMAttrModified","DOMCharacterDataModified","DOMNodeInserted","DOMNodeInsertedIntoDocument","DOMNodeRemoved","DOMNodeRemovedFromDocument","DOMSubtreeModified","DOMContentLoaded"]);this._createCategory(WebInspector.UIString("Device"),true,["deviceorientation","devicemotion"]);this._createCategory(WebInspector.UIString("Keyboard"),true,["keydown","keyup","keypress","input"]);this._createCategory(WebInspector.UIString("Load"),true,["load","beforeunload","unload","abort","error","hashchange","popstate"]);this._createCategory(WebInspector.UIString("Mouse"),true,["click","dblclick","mousedown","mouseup","mouseover","mousemove","mouseout","mousewheel"]);this._createCategory(WebInspector.UIString("Timer"),false,["setTimer","clearTimer","timerFired"]);this._createCategory(WebInspector.UIString("Touch"),true,["touchstart","touchmove","touchend","touchcancel"]);this._createCategory(WebInspector.UIString("WebGL"),false,["webglErrorFired","webglWarningFired"]);this._restoreBreakpoints();}
76 WebInspector.EventListenerBreakpointsSidebarPane.categotyListener="listener:";WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation="instrumentation:";WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI=function(eventName,auxData)
77 {if(!WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI){WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI={"instrumentation:setTimer":WebInspector.UIString("Set Timer"),"instrumentation:clearTimer":WebInspector.UIString("Clear Timer"),"instrumentation:timerFired":WebInspector.UIString("Timer Fired"),"instrumentation:requestAnimationFrame":WebInspector.UIString("Request Animation Frame"),"instrumentation:cancelAnimationFrame":WebInspector.UIString("Cancel Animation Frame"),"instrumentation:animationFrameFired":WebInspector.UIString("Animation Frame Fired"),"instrumentation:webglErrorFired":WebInspector.UIString("WebGL Error Fired"),"instrumentation:webglWarningFired":WebInspector.UIString("WebGL Warning Fired")};}
78 if(auxData){if(eventName==="instrumentation:webglErrorFired"&&auxData["webglErrorName"]){var errorName=auxData["webglErrorName"];errorName=errorName.replace(/^.*(0x[0-9a-f]+).*$/i,"$1");return WebInspector.UIString("WebGL Error Fired (%s)",errorName);}}
79 return WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI[eventName]||eventName.substring(eventName.indexOf(":")+1);}
80 WebInspector.EventListenerBreakpointsSidebarPane.prototype={_createCategory:function(name,isDOMEvent,eventNames)
81 {var categoryItem={};categoryItem.element=new TreeElement(name);this.categoriesTreeOutline.appendChild(categoryItem.element);categoryItem.element.listItemElement.classList.add("event-category");categoryItem.element.selectable=true;categoryItem.checkbox=this._createCheckbox(categoryItem.element);categoryItem.checkbox.addEventListener("click",this._categoryCheckboxClicked.bind(this,categoryItem),true);categoryItem.children={};for(var i=0;i<eventNames.length;++i){var eventName=(isDOMEvent?WebInspector.EventListenerBreakpointsSidebarPane.categotyListener:WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation)+eventNames[i];var breakpointItem={};var title=WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName);breakpointItem.element=new TreeElement(title);categoryItem.element.appendChild(breakpointItem.element);var hitMarker=document.createElement("div");hitMarker.className="breakpoint-hit-marker";breakpointItem.element.listItemElement.appendChild(hitMarker);breakpointItem.element.listItemElement.classList.add("source-code");breakpointItem.element.selectable=false;breakpointItem.checkbox=this._createCheckbox(breakpointItem.element);breakpointItem.checkbox.addEventListener("click",this._breakpointCheckboxClicked.bind(this,eventName),true);breakpointItem.parent=categoryItem;this._breakpointItems[eventName]=breakpointItem;categoryItem.children[eventName]=breakpointItem;}},_createCheckbox:function(treeElement)
82 {var checkbox=document.createElement("input");checkbox.className="checkbox-elem";checkbox.type="checkbox";treeElement.listItemElement.insertBefore(checkbox,treeElement.listItemElement.firstChild);return checkbox;},_categoryCheckboxClicked:function(categoryItem)
83 {var checked=categoryItem.checkbox.checked;for(var eventName in categoryItem.children){var breakpointItem=categoryItem.children[eventName];if(breakpointItem.checkbox.checked===checked)
84 continue;if(checked)
85 this._setBreakpoint(eventName);else
86 this._removeBreakpoint(eventName);}
87 this._saveBreakpoints();},_breakpointCheckboxClicked:function(eventName,event)
88 {if(event.target.checked)
89 this._setBreakpoint(eventName);else
90 this._removeBreakpoint(eventName);this._saveBreakpoints();},_setBreakpoint:function(eventName)
91 {var breakpointItem=this._breakpointItems[eventName];if(!breakpointItem)
92 return;breakpointItem.checkbox.checked=true;if(eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener))
93 DOMDebuggerAgent.setEventListenerBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener.length));else if(eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation))
94 DOMDebuggerAgent.setInstrumentationBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation.length));this._updateCategoryCheckbox(breakpointItem.parent);},_removeBreakpoint:function(eventName)
95 {var breakpointItem=this._breakpointItems[eventName];if(!breakpointItem)
96 return;breakpointItem.checkbox.checked=false;if(eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener))
97 DOMDebuggerAgent.removeEventListenerBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener.length));else if(eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation))
98 DOMDebuggerAgent.removeInstrumentationBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation.length));this._updateCategoryCheckbox(breakpointItem.parent);},_updateCategoryCheckbox:function(categoryItem)
99 {var hasEnabled=false,hasDisabled=false;for(var eventName in categoryItem.children){var breakpointItem=categoryItem.children[eventName];if(breakpointItem.checkbox.checked)
100 hasEnabled=true;else
101 hasDisabled=true;}
102 categoryItem.checkbox.checked=hasEnabled;categoryItem.checkbox.indeterminate=hasEnabled&&hasDisabled;},highlightBreakpoint:function(eventName)
103 {var breakpointItem=this._breakpointItems[eventName];if(!breakpointItem)
104 return;this.expand();breakpointItem.parent.element.expand();breakpointItem.element.listItemElement.classList.add("breakpoint-hit");this._highlightedElement=breakpointItem.element.listItemElement;},clearBreakpointHighlight:function()
105 {if(this._highlightedElement){this._highlightedElement.classList.remove("breakpoint-hit");delete this._highlightedElement;}},_saveBreakpoints:function()
106 {var breakpoints=[];for(var eventName in this._breakpointItems){if(this._breakpointItems[eventName].checkbox.checked)
107 breakpoints.push({eventName:eventName});}
108 WebInspector.settings.eventListenerBreakpoints.set(breakpoints);},_restoreBreakpoints:function()
109 {var breakpoints=WebInspector.settings.eventListenerBreakpoints.get();for(var i=0;i<breakpoints.length;++i){var breakpoint=breakpoints[i];if(breakpoint&&typeof breakpoint.eventName==="string")
110 this._setBreakpoint(breakpoint.eventName);}},__proto__:WebInspector.SidebarPane.prototype};WebInspector.CallStackSidebarPane=function()
111 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Call Stack"));this.bodyElement.addEventListener("keydown",this._keyDown.bind(this),true);this.bodyElement.tabIndex=0;var asyncCheckbox=this.titleElement.appendChild(WebInspector.SettingsTab.createSettingCheckbox(WebInspector.UIString("Async"),WebInspector.settings.enableAsyncStackTraces,true,undefined,WebInspector.UIString("Capture async stack traces")));asyncCheckbox.classList.add("scripts-callstack-async");asyncCheckbox.addEventListener("click",consumeEvent,false);WebInspector.settings.enableAsyncStackTraces.addChangeListener(this._asyncStackTracesStateChanged,this);}
112 WebInspector.CallStackSidebarPane.Events={CallFrameRestarted:"CallFrameRestarted",CallFrameSelected:"CallFrameSelected"}
113 WebInspector.CallStackSidebarPane.prototype={update:function(callFrames,asyncStackTrace)
114 {this.bodyElement.removeChildren();delete this._statusMessageElement;this.placards=[];if(!callFrames){var infoElement=this.bodyElement.createChild("div","info");infoElement.textContent=WebInspector.UIString("Not Paused");return;}
115 this._appendSidebarPlacards(callFrames);while(asyncStackTrace){var title="["+(asyncStackTrace.description||WebInspector.UIString("Async Call"))+"]";var asyncPlacard=new WebInspector.Placard(title,"");this.bodyElement.appendChild(asyncPlacard.element);this._appendSidebarPlacards(asyncStackTrace.callFrames,asyncPlacard);asyncStackTrace=asyncStackTrace.asyncStackTrace;}},_appendSidebarPlacards:function(callFrames,asyncPlacard)
116 {for(var i=0,n=callFrames.length;i<n;++i){var placard=new WebInspector.CallStackSidebarPane.Placard(callFrames[i],asyncPlacard);placard.element.addEventListener("click",this._placardSelected.bind(this,placard),false);placard.element.addEventListener("contextmenu",this._placardContextMenu.bind(this,placard),true);if(!i&&asyncPlacard){asyncPlacard.element.addEventListener("click",this._placardSelected.bind(this,placard),false);asyncPlacard.element.addEventListener("contextmenu",this._placardContextMenu.bind(this,placard),true);}
117 this.placards.push(placard);this.bodyElement.appendChild(placard.element);}},_placardContextMenu:function(placard,event)
118 {var contextMenu=new WebInspector.ContextMenu(event);if(!placard._callFrame.isAsync())
119 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Restart frame":"Restart Frame"),this._restartFrame.bind(this,placard));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Copy stack trace":"Copy Stack Trace"),this._copyStackTrace.bind(this));contextMenu.show();},_restartFrame:function(placard)
120 {placard._callFrame.restart();this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.CallFrameRestarted,placard._callFrame);},_asyncStackTracesStateChanged:function()
121 {var enabled=WebInspector.settings.enableAsyncStackTraces.get();if(!enabled&&this.placards)
122 this._removeAsyncPlacards();},_removeAsyncPlacards:function()
123 {var shouldSelectTopFrame=false;var lastSyncPlacardIndex=-1;for(var i=0;i<this.placards.length;++i){var placard=this.placards[i];if(placard._asyncPlacard){if(placard.selected)
124 shouldSelectTopFrame=true;placard._asyncPlacard.element.remove();placard.element.remove();}else{lastSyncPlacardIndex=i;}}
125 this.placards.length=lastSyncPlacardIndex+1;if(shouldSelectTopFrame)
126 this._selectPlacardByIndex(0);},setSelectedCallFrame:function(x)
127 {for(var i=0;i<this.placards.length;++i){var placard=this.placards[i];placard.selected=(placard._callFrame===x);}},_selectNextCallFrameOnStack:function()
128 {var index=this._selectedCallFrameIndex();if(index===-1)
129 return false;return this._selectPlacardByIndex(index+1);},_selectPreviousCallFrameOnStack:function()
130 {var index=this._selectedCallFrameIndex();if(index===-1)
131 return false;return this._selectPlacardByIndex(index-1);},_selectPlacardByIndex:function(index)
132 {if(index<0||index>=this.placards.length)
133 return false;this._placardSelected(this.placards[index]);return true;},_selectedCallFrameIndex:function()
134 {var selectedCallFrame=WebInspector.debuggerModel.selectedCallFrame();if(!selectedCallFrame)
135 return-1;for(var i=0;i<this.placards.length;++i){var placard=this.placards[i];if(placard._callFrame===selectedCallFrame)
136 return i;}
137 return-1;},_placardSelected:function(placard)
138 {placard.element.scrollIntoViewIfNeeded();this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.CallFrameSelected,placard._callFrame);},_copyStackTrace:function()
139 {var text="";for(var i=0;i<this.placards.length;++i){if(i&&this.placards[i]._asyncPlacard!==this.placards[i-1]._asyncPlacard)
140 text+=this.placards[i]._asyncPlacard.title+"\n";text+=this.placards[i].title+" ("+this.placards[i].subtitle+")\n";}
141 InspectorFrontendHost.copyText(text);},registerShortcuts:function(registerShortcutDelegate)
142 {registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.NextCallFrame,this._selectNextCallFrameOnStack.bind(this));registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.PrevCallFrame,this._selectPreviousCallFrameOnStack.bind(this));},setStatus:function(status)
143 {if(!this._statusMessageElement)
144 this._statusMessageElement=this.bodyElement.createChild("div","info");if(typeof status==="string"){this._statusMessageElement.textContent=status;}else{this._statusMessageElement.removeChildren();this._statusMessageElement.appendChild(status);}},_keyDown:function(event)
145 {if(event.altKey||event.shiftKey||event.metaKey||event.ctrlKey)
146 return;if(event.keyIdentifier==="Up"&&this._selectPreviousCallFrameOnStack()||event.keyIdentifier==="Down"&&this._selectNextCallFrameOnStack())
147 event.consume(true);},__proto__:WebInspector.SidebarPane.prototype}
148 WebInspector.CallStackSidebarPane.Placard=function(callFrame,asyncPlacard)
149 {WebInspector.Placard.call(this,callFrame.functionName||WebInspector.UIString("(anonymous function)"),"");callFrame.createLiveLocation(this._update.bind(this));this._callFrame=callFrame;this._asyncPlacard=asyncPlacard;}
150 WebInspector.CallStackSidebarPane.Placard.prototype={_update:function(uiLocation)
151 {this.subtitle=uiLocation.linkText().trimMiddle(100);},__proto__:WebInspector.Placard.prototype};WebInspector.HistoryEntry=function(){}
152 WebInspector.HistoryEntry.prototype={valid:function(){},reveal:function(){}};WebInspector.SimpleHistoryManager=function(historyDepth)
153 {this._entries=[];this._activeEntryIndex=-1;this._coalescingReadonly=0;this._historyDepth=historyDepth;}
154 WebInspector.SimpleHistoryManager.prototype={readOnlyLock:function()
155 {++this._coalescingReadonly;},releaseReadOnlyLock:function()
156 {--this._coalescingReadonly;},readOnly:function()
157 {return!!this._coalescingReadonly;},filterOut:function(filterOutCallback)
158 {if(this.readOnly())
159 return;var filteredEntries=[];var removedBeforeActiveEntry=0;for(var i=0;i<this._entries.length;++i){if(!filterOutCallback(this._entries[i])){filteredEntries.push(this._entries[i]);}else if(i<=this._activeEntryIndex)
160 ++removedBeforeActiveEntry;}
161 this._entries=filteredEntries;this._activeEntryIndex=Math.max(0,this._activeEntryIndex-removedBeforeActiveEntry);},empty:function()
162 {return!this._entries.length;},active:function()
163 {return this.empty()?null:this._entries[this._activeEntryIndex];},push:function(entry)
164 {if(this.readOnly())
165 return;if(!this.empty())
166 this._entries.splice(this._activeEntryIndex+1);this._entries.push(entry);if(this._entries.length>this._historyDepth)
167 this._entries.shift();this._activeEntryIndex=this._entries.length-1;},rollback:function()
168 {if(this.empty())
169 return false;var revealIndex=this._activeEntryIndex-1;while(revealIndex>=0&&!this._entries[revealIndex].valid())
170 --revealIndex;if(revealIndex<0)
171 return false;this.readOnlyLock();this._entries[revealIndex].reveal();this.releaseReadOnlyLock();this._activeEntryIndex=revealIndex;return true;},rollover:function()
172 {var revealIndex=this._activeEntryIndex+1;while(revealIndex<this._entries.length&&!this._entries[revealIndex].valid())
173 ++revealIndex;if(revealIndex>=this._entries.length)
174 return false;this.readOnlyLock();this._entries[revealIndex].reveal();this.releaseReadOnlyLock();this._activeEntryIndex=revealIndex;return true;},};;WebInspector.EditingLocationHistoryManager=function(sourcesPanel,currentSourceFrameCallback)
175 {this._sourcesPanel=sourcesPanel;this._historyManager=new WebInspector.SimpleHistoryManager(WebInspector.EditingLocationHistoryManager.HistoryDepth);this._currentSourceFrameCallback=currentSourceFrameCallback;}
176 WebInspector.EditingLocationHistoryManager.HistoryDepth=20;WebInspector.EditingLocationHistoryManager.prototype={trackSourceFrameCursorJumps:function(sourceFrame)
177 {sourceFrame.addEventListener(WebInspector.SourceFrame.Events.JumpHappened,this._onJumpHappened.bind(this));},_onJumpHappened:function(event)
178 {if(event.data.from)
179 this._updateActiveState(event.data.from);if(event.data.to)
180 this._pushActiveState(event.data.to);},rollback:function()
181 {this._historyManager.rollback();},rollover:function()
182 {this._historyManager.rollover();},updateCurrentState:function()
183 {var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
184 return;this._updateActiveState(sourceFrame.textEditor.selection());},pushNewState:function()
185 {var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
186 return;this._pushActiveState(sourceFrame.textEditor.selection());},_updateActiveState:function(selection)
187 {var active=this._historyManager.active();if(!active)
188 return;var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
189 return;var entry=new WebInspector.EditingLocationHistoryEntry(this._sourcesPanel,this,sourceFrame,selection);active.merge(entry);},_pushActiveState:function(selection)
190 {var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
191 return;var entry=new WebInspector.EditingLocationHistoryEntry(this._sourcesPanel,this,sourceFrame,selection);this._historyManager.push(entry);},removeHistoryForSourceCode:function(uiSourceCode)
192 {function filterOut(entry)
193 {return entry._projectId===uiSourceCode.project().id()&&entry._path===uiSourceCode.path();}
194 this._historyManager.filterOut(filterOut);},}
195 WebInspector.EditingLocationHistoryEntry=function(sourcesPanel,editingLocationManager,sourceFrame,selection)
196 {this._sourcesPanel=sourcesPanel;this._editingLocationManager=editingLocationManager;var uiSourceCode=sourceFrame.uiSourceCode();this._projectId=uiSourceCode.project().id();this._path=uiSourceCode.path();var position=this._positionFromSelection(selection);this._positionHandle=sourceFrame.textEditor.textEditorPositionHandle(position.lineNumber,position.columnNumber);}
197 WebInspector.EditingLocationHistoryEntry.prototype={merge:function(entry)
198 {if(this._projectId!==entry._projectId||this._path!==entry._path)
199 return;this._positionHandle=entry._positionHandle;},_positionFromSelection:function(selection)
200 {return{lineNumber:selection.endLine,columnNumber:selection.endColumn};},valid:function()
201 {var position=this._positionHandle.resolve();var uiSourceCode=WebInspector.workspace.project(this._projectId).uiSourceCode(this._path);return!!(position&&uiSourceCode);},reveal:function()
202 {var position=this._positionHandle.resolve();var uiSourceCode=WebInspector.workspace.project(this._projectId).uiSourceCode(this._path);if(!position||!uiSourceCode)
203 return;this._editingLocationManager.updateCurrentState();this._sourcesPanel.showUISourceCode(uiSourceCode,position.lineNumber,position.columnNumber);}};;WebInspector.FilePathScoreFunction=function(query)
204 {this._query=query;this._queryUpperCase=query.toUpperCase();this._score=null;this._sequence=null;this._dataUpperCase="";this._fileNameIndex=0;}
205 WebInspector.FilePathScoreFunction.filterRegex=function(query)
206 {const toEscape=String.regexSpecialCharacters();var regexString="";for(var i=0;i<query.length;++i){var c=query.charAt(i);if(toEscape.indexOf(c)!==-1)
207 c="\\"+c;if(i)
208 regexString+="[^"+c+"]*";regexString+=c;}
209 return new RegExp(regexString,"i");}
210 WebInspector.FilePathScoreFunction.prototype={score:function(data,matchIndexes)
211 {if(!data||!this._query)
212 return 0;var n=this._query.length;var m=data.length;if(!this._score||this._score.length<n*m){this._score=new Int32Array(n*m*2);this._sequence=new Int32Array(n*m*2);}
213 var score=this._score;var sequence=(this._sequence);this._dataUpperCase=data.toUpperCase();this._fileNameIndex=data.lastIndexOf("/");for(var i=0;i<n;++i){for(var j=0;j<m;++j){var skipCharScore=j===0?0:score[i*m+j-1];var prevCharScore=i===0||j===0?0:score[(i-1)*m+j-1];var consecutiveMatch=i===0||j===0?0:sequence[(i-1)*m+j-1];var pickCharScore=this._match(this._query,data,i,j,consecutiveMatch);if(pickCharScore&&prevCharScore+pickCharScore>skipCharScore){sequence[i*m+j]=consecutiveMatch+1;score[i*m+j]=(prevCharScore+pickCharScore);}else{sequence[i*m+j]=0;score[i*m+j]=skipCharScore;}}}
214 if(matchIndexes)
215 this._restoreMatchIndexes(sequence,n,m,matchIndexes);return score[n*m-1];},_testWordStart:function(data,j)
216 {var prevChar=data.charAt(j-1);return j===0||prevChar==="_"||prevChar==="-"||prevChar==="/"||(data[j-1]!==this._dataUpperCase[j-1]&&data[j]===this._dataUpperCase[j]);},_restoreMatchIndexes:function(sequence,n,m,out)
217 {var i=n-1,j=m-1;while(i>=0&&j>=0){switch(sequence[i*m+j]){case 0:--j;break;default:out.push(j);--i;--j;break;}}
218 out.reverse();},_singleCharScore:function(query,data,i,j)
219 {var isWordStart=this._testWordStart(data,j);var isFileName=j>this._fileNameIndex;var isPathTokenStart=j===0||data[j-1]==="/";var isCapsMatch=query[i]===data[j]&&query[i]==this._queryUpperCase[i];var score=10;if(isPathTokenStart)
220 score+=4;if(isWordStart)
221 score+=2;if(isCapsMatch)
222 score+=6;if(isFileName)
223 score+=4;if(j===this._fileNameIndex+1&&i===0)
224 score+=5;if(isFileName&&isWordStart)
225 score+=3;return score;},_sequenceCharScore:function(query,data,i,j,sequenceLength)
226 {var isFileName=j>this._fileNameIndex;var isPathTokenStart=j===0||data[j-1]==="/";var score=10;if(isFileName)
227 score+=4;if(isPathTokenStart)
228 score+=5;score+=sequenceLength*4;return score;},_match:function(query,data,i,j,consecutiveMatch)
229 {if(this._queryUpperCase[i]!==this._dataUpperCase[j])
230 return 0;if(!consecutiveMatch)
231 return this._singleCharScore(query,data,i,j);else
232 return this._sequenceCharScore(query,data,i,j-consecutiveMatch,consecutiveMatch);},};WebInspector.FilteredItemSelectionDialog=function(delegate)
233 {WebInspector.DialogDelegate.call(this);var xhr=new XMLHttpRequest();xhr.open("GET","filteredItemSelectionDialog.css",false);xhr.send(null);this.element=document.createElement("div");this.element.className="filtered-item-list-dialog";this.element.addEventListener("keydown",this._onKeyDown.bind(this),false);var styleElement=this.element.createChild("style");styleElement.type="text/css";styleElement.textContent=xhr.responseText;this._promptElement=this.element.createChild("input","monospace");this._promptElement.addEventListener("input",this._onInput.bind(this),false);this._promptElement.type="text";this._promptElement.setAttribute("spellcheck","false");this._filteredItems=[];this._viewportControl=new WebInspector.ViewportControl(this);this._itemElementsContainer=this._viewportControl.element;this._itemElementsContainer.classList.add("container");this._itemElementsContainer.classList.add("monospace");this._itemElementsContainer.addEventListener("click",this._onClick.bind(this),false);this.element.appendChild(this._itemElementsContainer);this._delegate=delegate;this._delegate.setRefreshCallback(this._itemsLoaded.bind(this));this._itemsLoaded();this._shouldShowMatchingItems=true;}
234 WebInspector.FilteredItemSelectionDialog.prototype={position:function(element,relativeToElement)
235 {const minWidth=500;const minHeight=204;var width=Math.max(relativeToElement.offsetWidth*2/3,minWidth);var height=Math.max(relativeToElement.offsetHeight*2/3,minHeight);this.element.style.width=width+"px";const shadowPadding=20;element.positionAt(relativeToElement.totalOffsetLeft()+Math.max((relativeToElement.offsetWidth-width-2*shadowPadding)/2,shadowPadding),relativeToElement.totalOffsetTop()+Math.max((relativeToElement.offsetHeight-height-2*shadowPadding)/2,shadowPadding));this._dialogHeight=height;this._updateShowMatchingItems();},focus:function()
236 {WebInspector.setCurrentFocusElement(this._promptElement);if(this._filteredItems.length&&this._viewportControl.lastVisibleIndex()===-1)
237 this._viewportControl.refresh();},willHide:function()
238 {if(this._isHiding)
239 return;this._isHiding=true;this._delegate.dispose();if(this._filterTimer)
240 clearTimeout(this._filterTimer);},renderAsTwoRows:function()
241 {this._renderAsTwoRows=true;},onEnter:function()
242 {if(!this._delegate.itemCount())
243 return;this._delegate.selectItem(this._filteredItems[this._selectedIndexInFiltered],this._promptElement.value.trim());},_itemsLoaded:function()
244 {if(this._loadTimeout)
245 return;this._loadTimeout=setTimeout(this._updateAfterItemsLoaded.bind(this),0);},_updateAfterItemsLoaded:function()
246 {delete this._loadTimeout;this._filterItems();},_createItemElement:function(index)
247 {var itemElement=document.createElement("div");itemElement.className="filtered-item-list-dialog-item "+(this._renderAsTwoRows?"two-rows":"one-row");itemElement._titleElement=itemElement.createChild("span");itemElement._titleSuffixElement=itemElement.createChild("span");itemElement._subtitleElement=itemElement.createChild("div","filtered-item-list-dialog-subtitle");itemElement._subtitleElement.textContent="\u200B";itemElement._index=index;this._delegate.renderItem(index,this._promptElement.value.trim(),itemElement._titleElement,itemElement._subtitleElement);return itemElement;},setQuery:function(query)
248 {this._promptElement.value=query;this._scheduleFilter();},_filterItems:function()
249 {delete this._filterTimer;if(this._scoringTimer){clearTimeout(this._scoringTimer);delete this._scoringTimer;}
250 var query=this._delegate.rewriteQuery(this._promptElement.value.trim());this._query=query;var queryLength=query.length;var filterRegex=query?WebInspector.FilePathScoreFunction.filterRegex(query):null;var oldSelectedAbsoluteIndex=this._selectedIndexInFiltered?this._filteredItems[this._selectedIndexInFiltered]:null;var filteredItems=[];this._selectedIndexInFiltered=0;var bestScores=[];var bestItems=[];var bestItemsToCollect=100;var minBestScore=0;var overflowItems=[];scoreItems.call(this,0);function compareIntegers(a,b)
251 {return b-a;}
252 function scoreItems(fromIndex)
253 {var maxWorkItems=1000;var workDone=0;for(var i=fromIndex;i<this._delegate.itemCount()&&workDone<maxWorkItems;++i){if(filterRegex&&!filterRegex.test(this._delegate.itemKeyAt(i)))
254 continue;var score=this._delegate.itemScoreAt(i,query);if(query)
255 workDone++;if(score>minBestScore||bestScores.length<bestItemsToCollect){var index=insertionIndexForObjectInListSortedByFunction(score,bestScores,compareIntegers,true);bestScores.splice(index,0,score);bestItems.splice(index,0,i);if(bestScores.length>bestItemsToCollect){overflowItems.push(bestItems.peekLast());bestScores.length=bestItemsToCollect;bestItems.length=bestItemsToCollect;}
256 minBestScore=bestScores.peekLast();}else
257 filteredItems.push(i);}
258 if(i<this._delegate.itemCount()){this._scoringTimer=setTimeout(scoreItems.bind(this,i),0);return;}
259 delete this._scoringTimer;this._filteredItems=bestItems.concat(overflowItems).concat(filteredItems);for(var i=0;i<this._filteredItems.length;++i){if(this._filteredItems[i]===oldSelectedAbsoluteIndex){this._selectedIndexInFiltered=i;break;}}
260 this._viewportControl.refresh();if(!query)
261 this._selectedIndexInFiltered=0;this._updateSelection(this._selectedIndexInFiltered,false);}},_onInput:function(event)
262 {this._shouldShowMatchingItems=this._delegate.shouldShowMatchingItems(this._promptElement.value);this._updateShowMatchingItems();this._scheduleFilter();},_updateShowMatchingItems:function()
263 {this._itemElementsContainer.enableStyleClass("hidden",!this._shouldShowMatchingItems);this.element.style.height=this._shouldShowMatchingItems?this._dialogHeight+"px":"auto";},_onKeyDown:function(event)
264 {var newSelectedIndex=this._selectedIndexInFiltered;switch(event.keyCode){case WebInspector.KeyboardShortcut.Keys.Down.code:if(++newSelectedIndex>=this._filteredItems.length)
265 newSelectedIndex=this._filteredItems.length-1;this._updateSelection(newSelectedIndex,true);event.consume(true);break;case WebInspector.KeyboardShortcut.Keys.Up.code:if(--newSelectedIndex<0)
266 newSelectedIndex=0;this._updateSelection(newSelectedIndex,false);event.consume(true);break;case WebInspector.KeyboardShortcut.Keys.PageDown.code:newSelectedIndex=Math.min(newSelectedIndex+this._viewportControl.rowsPerViewport(),this._filteredItems.length-1);this._updateSelection(newSelectedIndex,true);event.consume(true);break;case WebInspector.KeyboardShortcut.Keys.PageUp.code:newSelectedIndex=Math.max(newSelectedIndex-this._viewportControl.rowsPerViewport(),0);this._updateSelection(newSelectedIndex,false);event.consume(true);break;default:}},_scheduleFilter:function()
267 {if(this._filterTimer)
268 return;this._filterTimer=setTimeout(this._filterItems.bind(this),0);},_updateSelection:function(index,makeLast)
269 {var element=this._viewportControl.renderedElementAt(this._selectedIndexInFiltered);if(element)
270 element.classList.remove("selected");this._viewportControl.scrollItemIntoView(index,makeLast);this._selectedIndexInFiltered=index;element=this._viewportControl.renderedElementAt(index);if(element)
271 element.classList.add("selected");},_onClick:function(event)
272 {var itemElement=event.target.enclosingNodeOrSelfWithClass("filtered-item-list-dialog-item");if(!itemElement)
273 return;this._delegate.selectItem(itemElement._index,this._promptElement.value.trim());WebInspector.Dialog.hide();},itemCount:function()
274 {return this._filteredItems.length;},itemElement:function(index)
275 {var delegateIndex=this._filteredItems[index];var element=this._createItemElement(delegateIndex);if(index===this._selectedIndexInFiltered)
276 element.classList.add("selected");return element;},__proto__:WebInspector.DialogDelegate.prototype}
277 WebInspector.SelectionDialogContentProvider=function()
278 {}
279 WebInspector.SelectionDialogContentProvider.prototype={setRefreshCallback:function(refreshCallback)
280 {this._refreshCallback=refreshCallback;},shouldShowMatchingItems:function(query)
281 {return true;},itemCount:function()
282 {return 0;},itemKeyAt:function(itemIndex)
283 {return"";},itemScoreAt:function(itemIndex,query)
284 {return 1;},renderItem:function(itemIndex,query,titleElement,subtitleElement)
285 {},highlightRanges:function(element,query)
286 {if(!query)
287 return false;function rangesForMatch(text,query)
288 {var sm=new difflib.SequenceMatcher(query,text);var opcodes=sm.get_opcodes();var ranges=[];for(var i=0;i<opcodes.length;++i){var opcode=opcodes[i];if(opcode[0]==="equal")
289 ranges.push(new WebInspector.SourceRange(opcode[3],opcode[4]-opcode[3]));else if(opcode[0]!=="insert")
290 return null;}
291 return ranges;}
292 var text=element.textContent;var ranges=rangesForMatch(text,query);if(!ranges)
293 ranges=rangesForMatch(text.toUpperCase(),query.toUpperCase());if(ranges){WebInspector.highlightRangesWithStyleClass(element,ranges,"highlight");return true;}
294 return false;},selectItem:function(itemIndex,promptValue)
295 {},refresh:function()
296 {this._refreshCallback();},rewriteQuery:function(query)
297 {return query;},dispose:function()
298 {}}
299 WebInspector.JavaScriptOutlineDialog=function(view,contentProvider,selectItemCallback)
300 {WebInspector.SelectionDialogContentProvider.call(this);this._functionItems=[];this._view=view;this._selectItemCallback=selectItemCallback;contentProvider.requestContent(this._contentAvailable.bind(this));}
301 WebInspector.JavaScriptOutlineDialog.show=function(view,contentProvider,selectItemCallback)
302 {if(WebInspector.Dialog.currentInstance())
303 return null;var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(new WebInspector.JavaScriptOutlineDialog(view,contentProvider,selectItemCallback));WebInspector.Dialog.show(view.element,filteredItemSelectionDialog);}
304 WebInspector.JavaScriptOutlineDialog.prototype={_contentAvailable:function(content)
305 {this._outlineWorker=new Worker("ScriptFormatterWorker.js");this._outlineWorker.onmessage=this._didBuildOutlineChunk.bind(this);const method="outline";this._outlineWorker.postMessage({method:method,params:{content:content}});},_didBuildOutlineChunk:function(event)
306 {var data=event.data;var chunk=data["chunk"];for(var i=0;i<chunk.length;++i)
307 this._functionItems.push(chunk[i]);if(data.total===data.index)
308 this.dispose();this.refresh();},itemCount:function()
309 {return this._functionItems.length;},itemKeyAt:function(itemIndex)
310 {return this._functionItems[itemIndex].name;},itemScoreAt:function(itemIndex,query)
311 {var item=this._functionItems[itemIndex];return-item.line;},renderItem:function(itemIndex,query,titleElement,subtitleElement)
312 {var item=this._functionItems[itemIndex];titleElement.textContent=item.name+(item.arguments?item.arguments:"");this.highlightRanges(titleElement,query);subtitleElement.textContent=":"+(item.line+1);},selectItem:function(itemIndex,promptValue)
313 {var lineNumber=this._functionItems[itemIndex].line;if(!isNaN(lineNumber)&&lineNumber>=0)
314 this._selectItemCallback(lineNumber,this._functionItems[itemIndex].column);},dispose:function()
315 {if(this._outlineWorker){this._outlineWorker.terminate();delete this._outlineWorker;}},__proto__:WebInspector.SelectionDialogContentProvider.prototype}
316 WebInspector.SelectUISourceCodeDialog=function(defaultScores)
317 {WebInspector.SelectionDialogContentProvider.call(this);this._uiSourceCodes=[];var projects=WebInspector.workspace.projects().filter(this.filterProject.bind(this));for(var i=0;i<projects.length;++i)
318 this._uiSourceCodes=this._uiSourceCodes.concat(projects[i].uiSourceCodes());this._defaultScores=defaultScores;this._scorer=new WebInspector.FilePathScoreFunction("");WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);}
319 WebInspector.SelectUISourceCodeDialog.prototype={uiSourceCodeSelected:function(uiSourceCode,lineNumber)
320 {},filterProject:function(project)
321 {return true;},itemCount:function()
322 {return this._uiSourceCodes.length;},itemKeyAt:function(itemIndex)
323 {return this._uiSourceCodes[itemIndex].fullDisplayName();},itemScoreAt:function(itemIndex,query)
324 {var uiSourceCode=this._uiSourceCodes[itemIndex];var score=this._defaultScores?(this._defaultScores.get(uiSourceCode)||0):0;if(!query||query.length<2)
325 return score;if(this._query!==query){this._query=query;this._scorer=new WebInspector.FilePathScoreFunction(query);}
326 var path=uiSourceCode.fullDisplayName();return score+10*this._scorer.score(path,null);},renderItem:function(itemIndex,query,titleElement,subtitleElement)
327 {query=this.rewriteQuery(query);var uiSourceCode=this._uiSourceCodes[itemIndex];titleElement.textContent=uiSourceCode.displayName()+(this._queryLineNumber?this._queryLineNumber:"");subtitleElement.textContent=uiSourceCode.fullDisplayName().trimEnd(100);var indexes=[];var score=new WebInspector.FilePathScoreFunction(query).score(subtitleElement.textContent,indexes);var fileNameIndex=subtitleElement.textContent.lastIndexOf("/");var ranges=[];for(var i=0;i<indexes.length;++i)
328 ranges.push({offset:indexes[i],length:1});if(indexes[0]>fileNameIndex){for(var i=0;i<ranges.length;++i)
329 ranges[i].offset-=fileNameIndex+1;return WebInspector.highlightRangesWithStyleClass(titleElement,ranges,"highlight");}else{return WebInspector.highlightRangesWithStyleClass(subtitleElement,ranges,"highlight");}},selectItem:function(itemIndex,promptValue)
330 {if(/^:\d+$/.test(promptValue.trimRight())){var lineNumber=parseInt(promptValue.trimRight().substring(1),10)-1;if(!isNaN(lineNumber)&&lineNumber>=0)
331 this.uiSourceCodeSelected(null,lineNumber);return;}
332 var lineNumberMatch=promptValue.match(/[^:]+\:([\d]*)$/);var lineNumber=lineNumberMatch?Math.max(parseInt(lineNumberMatch[1],10)-1,0):undefined;this.uiSourceCodeSelected(this._uiSourceCodes[itemIndex],lineNumber);},rewriteQuery:function(query)
333 {if(!query)
334 return query;query=query.trim();var lineNumberMatch=query.match(/([^:]+)(\:[\d]*)$/);this._queryLineNumber=lineNumberMatch?lineNumberMatch[2]:"";return lineNumberMatch?lineNumberMatch[1]:query;},_uiSourceCodeAdded:function(event)
335 {var uiSourceCode=(event.data);if(!this.filterProject(uiSourceCode.project()))
336 return;this._uiSourceCodes.push(uiSourceCode)
337 this.refresh();},dispose:function()
338 {WebInspector.workspace.removeEventListener(WebInspector.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);},__proto__:WebInspector.SelectionDialogContentProvider.prototype}
339 WebInspector.OpenResourceDialog=function(panel,defaultScores)
340 {WebInspector.SelectUISourceCodeDialog.call(this,defaultScores);this._panel=panel;}
341 WebInspector.OpenResourceDialog.prototype={uiSourceCodeSelected:function(uiSourceCode,lineNumber)
342 {if(!uiSourceCode)
343 uiSourceCode=this._panel.currentUISourceCode();if(!uiSourceCode)
344 return;this._panel.showUISourceCode(uiSourceCode,lineNumber);},shouldShowMatchingItems:function(query)
345 {return!query.startsWith(":");},filterProject:function(project)
346 {return!project.isServiceProject();},__proto__:WebInspector.SelectUISourceCodeDialog.prototype}
347 WebInspector.OpenResourceDialog.show=function(panel,relativeToElement,name,defaultScores)
348 {if(WebInspector.Dialog.currentInstance())
349 return;var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel,defaultScores));filteredItemSelectionDialog.renderAsTwoRows();if(name)
350 filteredItemSelectionDialog.setQuery(name);WebInspector.Dialog.show(relativeToElement,filteredItemSelectionDialog);}
351 WebInspector.SelectUISourceCodeForProjectTypeDialog=function(type,callback)
352 {this._type=type;WebInspector.SelectUISourceCodeDialog.call(this);this._callback=callback;}
353 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype={uiSourceCodeSelected:function(uiSourceCode,lineNumber)
354 {this._callback(uiSourceCode);},filterProject:function(project)
355 {return project.type()===this._type;},__proto__:WebInspector.SelectUISourceCodeDialog.prototype}
356 WebInspector.SelectUISourceCodeForProjectTypeDialog.show=function(name,type,callback,relativeToElement)
357 {if(WebInspector.Dialog.currentInstance())
358 return;var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type,callback));filteredItemSelectionDialog.setQuery(name);filteredItemSelectionDialog.renderAsTwoRows();WebInspector.Dialog.show(relativeToElement,filteredItemSelectionDialog);};WebInspector.UISourceCodeFrame=function(uiSourceCode)
359 {this._uiSourceCode=uiSourceCode;WebInspector.SourceFrame.call(this,this._uiSourceCode);WebInspector.settings.textEditorAutocompletion.addChangeListener(this._enableAutocompletionIfNeeded,this);this._enableAutocompletionIfNeeded();this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged,this._onFormattedChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._onWorkingCopyChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._onWorkingCopyCommitted,this);this._updateStyle();}
360 WebInspector.UISourceCodeFrame.prototype={uiSourceCode:function()
361 {return this._uiSourceCode;},_enableAutocompletionIfNeeded:function()
362 {this.textEditor.setCompletionDictionary(WebInspector.settings.textEditorAutocompletion.get()?new WebInspector.SampleCompletionDictionary():null);},wasShown:function()
363 {WebInspector.SourceFrame.prototype.wasShown.call(this);this._boundWindowFocused=this._windowFocused.bind(this);window.addEventListener("focus",this._boundWindowFocused,false);this._checkContentUpdated();},willHide:function()
364 {WebInspector.SourceFrame.prototype.willHide.call(this);window.removeEventListener("focus",this._boundWindowFocused,false);delete this._boundWindowFocused;this._uiSourceCode.removeWorkingCopyGetter();},canEditSource:function()
365 {return this._uiSourceCode.isEditable();},_windowFocused:function(event)
366 {this._checkContentUpdated();},_checkContentUpdated:function()
367 {if(!this.loaded||!this.isShowing())
368 return;this._uiSourceCode.checkContentUpdated();},commitEditing:function(text)
369 {if(!this._uiSourceCode.isDirty())
370 return;this._muteSourceCodeEvents=true;this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));delete this._muteSourceCodeEvents;},onTextChanged:function(oldRange,newRange)
371 {WebInspector.SourceFrame.prototype.onTextChanged.call(this,oldRange,newRange);if(this._isSettingContent)
372 return;this._muteSourceCodeEvents=true;if(this._textEditor.isClean())
373 this._uiSourceCode.resetWorkingCopy();else
374 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(this._textEditor));delete this._muteSourceCodeEvents;},_didEditContent:function(error)
375 {if(error){WebInspector.log(error,WebInspector.ConsoleMessage.MessageLevel.Error,true);return;}},beforeFormattedChange:function(){},_onFormattedChanged:function(event)
376 {this.beforeFormattedChange();var content=(event.data.content);this._textEditor.setReadOnly(this._uiSourceCode.formatted());var selection=this._textEditor.selection();this._innerSetContent(content);var start=null;var end=null;if(this._uiSourceCode.formatted()){start=event.data.newFormatter.originalToFormatted(selection.startLine,selection.startColumn);end=event.data.newFormatter.originalToFormatted(selection.endLine,selection.endColumn);}else{start=event.data.oldFormatter.formattedToOriginal(selection.startLine,selection.startColumn);end=event.data.oldFormatter.formattedToOriginal(selection.endLine,selection.endColumn);}
377 this.textEditor.setSelection(new WebInspector.TextRange(start[0],start[1],end[0],end[1]));this.textEditor.revealLine(start[0]);},_onWorkingCopyChanged:function(event)
378 {if(this._muteSourceCodeEvents)
379 return;this._innerSetContent(this._uiSourceCode.workingCopy());this.onUISourceCodeContentChanged();},_onWorkingCopyCommitted:function(event)
380 {if(!this._muteSourceCodeEvents){this._innerSetContent(this._uiSourceCode.workingCopy());this.onUISourceCodeContentChanged();}
381 this._textEditor.markClean();this._updateStyle();},_updateStyle:function()
382 {this.element.enableStyleClass("source-frame-unsaved-committed-changes",this._uiSourceCode.hasUnsavedCommittedChanges());},onUISourceCodeContentChanged:function()
383 {},_innerSetContent:function(content)
384 {this._isSettingContent=true;this.setContent(content);delete this._isSettingContent;},populateTextAreaContextMenu:function(contextMenu,lineNumber)
385 {WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this,contextMenu,lineNumber);contextMenu.appendApplicableItems(this._uiSourceCode);contextMenu.appendSeparator();},dispose:function()
386 {this.detach();},__proto__:WebInspector.SourceFrame.prototype};WebInspector.JavaScriptSourceFrame=function(scriptsPanel,uiSourceCode)
387 {this._scriptsPanel=scriptsPanel;this._breakpointManager=WebInspector.breakpointManager;this._uiSourceCode=uiSourceCode;WebInspector.UISourceCodeFrame.call(this,uiSourceCode);if(uiSourceCode.project().type()===WebInspector.projectTypes.Debugger)
388 this.element.classList.add("source-frame-debugger-script");this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.textEditor.element,this._getPopoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),this._onHidePopover.bind(this),true);this.textEditor.element.addEventListener("keydown",this._onKeyDown.bind(this),true);this.textEditor.addEventListener(WebInspector.TextEditor.Events.GutterClick,this._handleGutterClick.bind(this),this);this.textEditor.element.addEventListener("mousedown",this._onMouseDownAndClick.bind(this,true),true);this.textEditor.element.addEventListener("click",this._onMouseDownAndClick.bind(this,false),true);this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded,this._breakpointAdded,this);this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved,this._breakpointRemoved,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded,this._consoleMessageAdded,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageRemoved,this._consoleMessageRemoved,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared,this._consoleMessagesCleared,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceMappingChanged,this._onSourceMappingChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._workingCopyChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._workingCopyCommitted,this);this._registerShortcuts();this._updateScriptFile();}
389 WebInspector.JavaScriptSourceFrame.prototype={_registerShortcuts:function()
390 {var shortcutKeys=WebInspector.ShortcutsScreen.SourcesPanelShortcuts;for(var i=0;i<shortcutKeys.EvaluateSelectionInConsole.length;++i){var keyDescriptor=shortcutKeys.EvaluateSelectionInConsole[i];this.addShortcut(keyDescriptor.key,this._evaluateSelectionInConsole.bind(this));}
391 for(var i=0;i<shortcutKeys.AddSelectionToWatch.length;++i){var keyDescriptor=shortcutKeys.AddSelectionToWatch[i];this.addShortcut(keyDescriptor.key,this._addCurrentSelectionToWatch.bind(this));}},_addCurrentSelectionToWatch:function()
392 {var textSelection=this.textEditor.selection();if(textSelection&&!textSelection.isEmpty())
393 this._innerAddToWatch(this.textEditor.copyRange(textSelection));},_innerAddToWatch:function(expression)
394 {this._scriptsPanel.addToWatch(expression);},_evaluateSelectionInConsole:function()
395 {var selection=this.textEditor.selection();if(!selection||selection.isEmpty())
396 return false;WebInspector.evaluateInConsole(this.textEditor.copyRange(selection));return true;},wasShown:function()
397 {WebInspector.UISourceCodeFrame.prototype.wasShown.call(this);},willHide:function()
398 {WebInspector.UISourceCodeFrame.prototype.willHide.call(this);this._popoverHelper.hidePopover();},onUISourceCodeContentChanged:function()
399 {this._removeAllBreakpoints();WebInspector.UISourceCodeFrame.prototype.onUISourceCodeContentChanged.call(this);},populateLineGutterContextMenu:function(contextMenu,lineNumber)
400 {contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Continue to here":"Continue to Here"),this._continueToLine.bind(this,lineNumber));var breakpoint=this._breakpointManager.findBreakpoint(this._uiSourceCode,lineNumber);if(!breakpoint){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add breakpoint":"Add Breakpoint"),this._setBreakpoint.bind(this,lineNumber,"",true));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add conditional breakpoint…":"Add Conditional Breakpoint…"),this._editBreakpointCondition.bind(this,lineNumber));}else{contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove breakpoint":"Remove Breakpoint"),breakpoint.remove.bind(breakpoint));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Edit breakpoint…":"Edit Breakpoint…"),this._editBreakpointCondition.bind(this,lineNumber,breakpoint));if(breakpoint.enabled())
401 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Disable breakpoint":"Disable Breakpoint"),breakpoint.setEnabled.bind(breakpoint,false));else
402 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Enable breakpoint":"Enable Breakpoint"),breakpoint.setEnabled.bind(breakpoint,true));}},populateTextAreaContextMenu:function(contextMenu,lineNumber)
403 {var textSelection=this.textEditor.selection();if(textSelection&&!textSelection.isEmpty()){var selection=this.textEditor.copyRange(textSelection);var addToWatchLabel=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add to watch":"Add to Watch");contextMenu.appendItem(addToWatchLabel,this._innerAddToWatch.bind(this,selection));var evaluateLabel=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Evaluate in console":"Evaluate in Console");contextMenu.appendItem(evaluateLabel,WebInspector.evaluateInConsole.bind(WebInspector,selection));contextMenu.appendSeparator();}else if(!this._uiSourceCode.isEditable()&&this._uiSourceCode.contentType()===WebInspector.resourceTypes.Script){var liveEditLabel=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Live edit":"Live Edit");contextMenu.appendItem(liveEditLabel,liveEdit.bind(this));contextMenu.appendSeparator();}
404 function liveEdit()
405 {var liveEditUISourceCode=WebInspector.liveEditSupport.uiSourceCodeForLiveEdit(this._uiSourceCode);this._scriptsPanel.showUISourceCode(liveEditUISourceCode,lineNumber)}
406 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.call(this,contextMenu,lineNumber);},_workingCopyChanged:function(event)
407 {if(this._supportsEnabledBreakpointsWhileEditing()||this._scriptFile)
408 return;if(this._uiSourceCode.isDirty())
409 this._muteBreakpointsWhileEditing();else
410 this._restoreBreakpointsAfterEditing();},_workingCopyCommitted:function(event)
411 {if(this._supportsEnabledBreakpointsWhileEditing()||this._scriptFile)
412 return;this._restoreBreakpointsAfterEditing();},_didMergeToVM:function()
413 {if(this._supportsEnabledBreakpointsWhileEditing())
414 return;this._restoreBreakpointsAfterEditing();},_didDivergeFromVM:function()
415 {if(this._supportsEnabledBreakpointsWhileEditing())
416 return;this._muteBreakpointsWhileEditing();},_muteBreakpointsWhileEditing:function()
417 {if(this._muted)
418 return;for(var lineNumber=0;lineNumber<this._textEditor.linesCount;++lineNumber){var breakpointDecoration=this._textEditor.getAttribute(lineNumber,"breakpoint");if(!breakpointDecoration)
419 continue;this._removeBreakpointDecoration(lineNumber);this._addBreakpointDecoration(lineNumber,breakpointDecoration.condition,breakpointDecoration.enabled,true);}
420 this._muted=true;},_supportsEnabledBreakpointsWhileEditing:function()
421 {return this._uiSourceCode.project().type()===WebInspector.projectTypes.Snippets;},_restoreBreakpointsAfterEditing:function()
422 {delete this._muted;var breakpoints={};for(var lineNumber=0;lineNumber<this._textEditor.linesCount;++lineNumber){var breakpointDecoration=this._textEditor.getAttribute(lineNumber,"breakpoint");if(breakpointDecoration){breakpoints[lineNumber]=breakpointDecoration;this._removeBreakpointDecoration(lineNumber);}}
423 this._removeAllBreakpoints();for(var lineNumberString in breakpoints){var lineNumber=parseInt(lineNumberString,10);if(isNaN(lineNumber))
424 continue;var breakpointDecoration=breakpoints[lineNumberString];this._setBreakpoint(lineNumber,breakpointDecoration.condition,breakpointDecoration.enabled);}},_removeAllBreakpoints:function()
425 {var breakpoints=this._breakpointManager.breakpointsForUISourceCode(this._uiSourceCode);for(var i=0;i<breakpoints.length;++i)
426 breakpoints[i].remove();},_getPopoverAnchor:function(element,event)
427 {if(!WebInspector.debuggerModel.isPaused())
428 return null;var textPosition=this.textEditor.coordinatesToCursorPosition(event.x,event.y);if(!textPosition)
429 return null;var mouseLine=textPosition.startLine;var mouseColumn=textPosition.startColumn;var textSelection=this.textEditor.selection().normalize();if(textSelection&&!textSelection.isEmpty()){if(textSelection.startLine!==textSelection.endLine||textSelection.startLine!==mouseLine||mouseColumn<textSelection.startColumn||mouseColumn>textSelection.endColumn)
430 return null;var leftCorner=this.textEditor.cursorPositionToCoordinates(textSelection.startLine,textSelection.startColumn);var rightCorner=this.textEditor.cursorPositionToCoordinates(textSelection.endLine,textSelection.endColumn);var anchorBox=new AnchorBox(leftCorner.x,leftCorner.y,rightCorner.x-leftCorner.x,leftCorner.height);anchorBox.highlight={lineNumber:textSelection.startLine,startColumn:textSelection.startColumn,endColumn:textSelection.endColumn-1};anchorBox.forSelection=true;return anchorBox;}
431 var token=this.textEditor.tokenAtTextPosition(textPosition.startLine,textPosition.startColumn);if(!token)
432 return null;var lineNumber=textPosition.startLine;var line=this.textEditor.line(lineNumber);var tokenContent=line.substring(token.startColumn,token.endColumn+1);if(token.type!=="javascript-ident"&&(token.type!=="javascript-keyword"||tokenContent!=="this"))
433 return null;var leftCorner=this.textEditor.cursorPositionToCoordinates(lineNumber,token.startColumn);var rightCorner=this.textEditor.cursorPositionToCoordinates(lineNumber,token.endColumn+1);var anchorBox=new AnchorBox(leftCorner.x,leftCorner.y,rightCorner.x-leftCorner.x,leftCorner.height);anchorBox.highlight={lineNumber:lineNumber,startColumn:token.startColumn,endColumn:token.endColumn};return anchorBox;},_resolveObjectForPopover:function(anchorBox,showCallback,objectGroupName)
434 {function showObjectPopover(result,wasThrown)
435 {if(!WebInspector.debuggerModel.isPaused()||!result){this._popoverHelper.hidePopover();return;}
436 this._popoverAnchorBox=anchorBox;showCallback(WebInspector.RemoteObject.fromPayload(result),wasThrown,this._popoverAnchorBox);if(this._popoverAnchorBox){var highlightRange=new WebInspector.TextRange(lineNumber,startHighlight,lineNumber,endHighlight);this._popoverAnchorBox._highlightDescriptor=this.textEditor.highlightRange(highlightRange,"source-frame-eval-expression");}}
437 if(!WebInspector.debuggerModel.isPaused()){this._popoverHelper.hidePopover();return;}
438 var lineNumber=anchorBox.highlight.lineNumber;var startHighlight=anchorBox.highlight.startColumn;var endHighlight=anchorBox.highlight.endColumn;var line=this.textEditor.line(lineNumber);if(!anchorBox.forSelection){while(startHighlight>1&&line.charAt(startHighlight-1)==='.'){var token=this.textEditor.tokenAtTextPosition(lineNumber,startHighlight-2);if(!token){this._popoverHelper.hidePopover();return;}
439 startHighlight=token.startColumn;}}
440 var evaluationText=line.substring(startHighlight,endHighlight+1);var selectedCallFrame=WebInspector.debuggerModel.selectedCallFrame();selectedCallFrame.evaluate(evaluationText,objectGroupName,false,true,false,false,showObjectPopover.bind(this));},_onHidePopover:function()
441 {if(!this._popoverAnchorBox)
442 return;if(this._popoverAnchorBox._highlightDescriptor)
443 this.textEditor.removeHighlight(this._popoverAnchorBox._highlightDescriptor);delete this._popoverAnchorBox;},_addBreakpointDecoration:function(lineNumber,condition,enabled,mutedWhileEditing)
444 {var breakpoint={condition:condition,enabled:enabled};this.textEditor.setAttribute(lineNumber,"breakpoint",breakpoint);var disabled=!enabled||mutedWhileEditing;this.textEditor.addBreakpoint(lineNumber,disabled,!!condition);},_removeBreakpointDecoration:function(lineNumber)
445 {this.textEditor.removeAttribute(lineNumber,"breakpoint");this.textEditor.removeBreakpoint(lineNumber);},_onKeyDown:function(event)
446 {if(event.keyIdentifier==="U+001B"){if(this._popoverHelper.isPopoverVisible()){this._popoverHelper.hidePopover();event.consume();return;}
447 if(this._stepIntoMarkup&&WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)){this._stepIntoMarkup.stoptIteratingSelection();event.consume();return;}}},_editBreakpointCondition:function(lineNumber,breakpoint)
448 {this._conditionElement=this._createConditionElement(lineNumber);this.textEditor.addDecoration(lineNumber,this._conditionElement);function finishEditing(committed,element,newText)
449 {this.textEditor.removeDecoration(lineNumber,this._conditionElement);delete this._conditionEditorElement;delete this._conditionElement;if(!committed)
450 return;if(breakpoint)
451 breakpoint.setCondition(newText);else
452 this._setBreakpoint(lineNumber,newText,true);}
453 var config=new WebInspector.EditingConfig(finishEditing.bind(this,true),finishEditing.bind(this,false));WebInspector.startEditing(this._conditionEditorElement,config);this._conditionEditorElement.value=breakpoint?breakpoint.condition():"";this._conditionEditorElement.select();},_createConditionElement:function(lineNumber)
454 {var conditionElement=document.createElement("div");conditionElement.className="source-frame-breakpoint-condition";var labelElement=document.createElement("label");labelElement.className="source-frame-breakpoint-message";labelElement.htmlFor="source-frame-breakpoint-condition";labelElement.appendChild(document.createTextNode(WebInspector.UIString("The breakpoint on line %d will stop only if this expression is true:",lineNumber)));conditionElement.appendChild(labelElement);var editorElement=document.createElement("input");editorElement.id="source-frame-breakpoint-condition";editorElement.className="monospace";editorElement.type="text";conditionElement.appendChild(editorElement);this._conditionEditorElement=editorElement;return conditionElement;},setExecutionLine:function(lineNumber,callFrame)
455 {this._executionLineNumber=lineNumber;this._executionCallFrame=callFrame;if(this.loaded){this.textEditor.setExecutionLine(lineNumber);if(WebInspector.experimentsSettings.stepIntoSelection.isEnabled())
456 callFrame.getStepIntoLocations(locationsCallback.bind(this));}
457 function locationsCallback(locations)
458 {if(this._executionCallFrame!==callFrame||this._stepIntoMarkup)
459 return;this._stepIntoMarkup=WebInspector.JavaScriptSourceFrame.StepIntoMarkup.create(this,locations);if(this._stepIntoMarkup)
460 this._stepIntoMarkup.show();}},clearExecutionLine:function()
461 {if(this._stepIntoMarkup){this._stepIntoMarkup.dispose();delete this._stepIntoMarkup;}
462 if(this.loaded&&typeof this._executionLineNumber==="number")
463 this.textEditor.clearExecutionLine();delete this._executionLineNumber;delete this._executionCallFrame;},_lineNumberAfterEditing:function(lineNumber,oldRange,newRange)
464 {var shiftOffset=lineNumber<=oldRange.startLine?0:newRange.linesCount-oldRange.linesCount;if(lineNumber===oldRange.startLine){var whiteSpacesRegex=/^[\s\xA0]*$/;for(var i=0;lineNumber+i<=newRange.endLine;++i){if(!whiteSpacesRegex.test(this.textEditor.line(lineNumber+i))){shiftOffset=i;break;}}}
465 var newLineNumber=Math.max(0,lineNumber+shiftOffset);if(oldRange.startLine<lineNumber&&lineNumber<oldRange.endLine)
466 newLineNumber=oldRange.startLine;return newLineNumber;},_onMouseDownAndClick:function(isMouseDown,event)
467 {var markup=this._stepIntoMarkup;if(!markup)
468 return;var index=markup.findItemByCoordinates(event.x,event.y);if(typeof index==="undefined")
469 return;if(isMouseDown){event.consume();}else{var rawLocation=markup.getRawPosition(index);this._scriptsPanel.doStepIntoSelection(rawLocation);}},_shouldIgnoreExternalBreakpointEvents:function()
470 {if(this._supportsEnabledBreakpointsWhileEditing())
471 return false;if(this._muted)
472 return true;return this._scriptFile&&(this._scriptFile.isDivergingFromVM()||this._scriptFile.isMergingToVM());},_breakpointAdded:function(event)
473 {var uiLocation=(event.data.uiLocation);if(uiLocation.uiSourceCode!==this._uiSourceCode)
474 return;if(this._shouldIgnoreExternalBreakpointEvents())
475 return;var breakpoint=(event.data.breakpoint);if(this.loaded)
476 this._addBreakpointDecoration(uiLocation.lineNumber,breakpoint.condition(),breakpoint.enabled(),false);},_breakpointRemoved:function(event)
477 {var uiLocation=(event.data.uiLocation);if(uiLocation.uiSourceCode!==this._uiSourceCode)
478 return;if(this._shouldIgnoreExternalBreakpointEvents())
479 return;var breakpoint=(event.data.breakpoint);var remainingBreakpoint=this._breakpointManager.findBreakpoint(this._uiSourceCode,uiLocation.lineNumber);if(!remainingBreakpoint&&this.loaded)
480 this._removeBreakpointDecoration(uiLocation.lineNumber);},_consoleMessageAdded:function(event)
481 {var message=(event.data);if(this.loaded)
482 this.addMessageToSource(message.lineNumber,message.originalMessage);},_consoleMessageRemoved:function(event)
483 {var message=(event.data);if(this.loaded)
484 this.removeMessageFromSource(message.lineNumber,message.originalMessage);},_consoleMessagesCleared:function(event)
485 {this.clearMessages();},_onSourceMappingChanged:function(event)
486 {this._updateScriptFile();},_updateScriptFile:function()
487 {if(this._scriptFile){this._scriptFile.removeEventListener(WebInspector.ScriptFile.Events.DidMergeToVM,this._didMergeToVM,this);this._scriptFile.removeEventListener(WebInspector.ScriptFile.Events.DidDivergeFromVM,this._didDivergeFromVM,this);if(this._muted&&!this._uiSourceCode.isDirty())
488 this._restoreBreakpointsAfterEditing();}
489 this._scriptFile=this._uiSourceCode.scriptFile();if(this._scriptFile){this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidMergeToVM,this._didMergeToVM,this);this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidDivergeFromVM,this._didDivergeFromVM,this);if(this.loaded)
490 this._scriptFile.checkMapping();}},beforeFormattedChange:function()
491 {this.clearExecutionLine();},onTextEditorContentLoaded:function()
492 {if(typeof this._executionLineNumber==="number")
493 this.setExecutionLine(this._executionLineNumber,this._executionCallFrame);var breakpointLocations=this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);for(var i=0;i<breakpointLocations.length;++i)
494 this._breakpointAdded({data:breakpointLocations[i]});var messages=this._uiSourceCode.consoleMessages();for(var i=0;i<messages.length;++i){var message=messages[i];this.addMessageToSource(message.lineNumber,message.originalMessage);}
495 if(this._scriptFile)
496 this._scriptFile.checkMapping();},_handleGutterClick:function(event)
497 {if(this._muted)
498 return;var eventData=(event.data);var lineNumber=eventData.lineNumber;var eventObject=(eventData.event);if(eventObject.button!=0||eventObject.altKey||eventObject.ctrlKey||eventObject.metaKey)
499 return;this._toggleBreakpoint(lineNumber,eventObject.shiftKey);eventObject.consume(true);},_toggleBreakpoint:function(lineNumber,onlyDisable)
500 {var breakpoint=this._breakpointManager.findBreakpoint(this._uiSourceCode,lineNumber);if(breakpoint){if(onlyDisable)
501 breakpoint.setEnabled(!breakpoint.enabled());else
502 breakpoint.remove();}else
503 this._setBreakpoint(lineNumber,"",true);},toggleBreakpointOnCurrentLine:function()
504 {if(this._muted)
505 return;var selection=this.textEditor.selection();if(!selection)
506 return;this._toggleBreakpoint(selection.startLine,false);},_setBreakpoint:function(lineNumber,condition,enabled)
507 {this._breakpointManager.setBreakpoint(this._uiSourceCode,lineNumber,condition,enabled);WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.SetBreakpoint,url:this._uiSourceCode.originURL(),line:lineNumber,enabled:enabled});},_continueToLine:function(lineNumber)
508 {var rawLocation=(this._uiSourceCode.uiLocationToRawLocation(lineNumber,0));this._scriptsPanel.continueToLocation(rawLocation);},stepIntoMarkup:function()
509 {return this._stepIntoMarkup;},dispose:function()
510 {this._breakpointManager.removeEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded,this._breakpointAdded,this);this._breakpointManager.removeEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved,this._breakpointRemoved,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded,this._consoleMessageAdded,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ConsoleMessageRemoved,this._consoleMessageRemoved,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared,this._consoleMessagesCleared,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.SourceMappingChanged,this._onSourceMappingChanged,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._workingCopyChanged,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._workingCopyCommitted,this);WebInspector.UISourceCodeFrame.prototype.dispose.call(this);},__proto__:WebInspector.UISourceCodeFrame.prototype}
511 WebInspector.JavaScriptSourceFrame.StepIntoMarkup=function(rawPositions,editorRanges,firstToExecute,sourceFrame)
512 {this._positions=rawPositions;this._editorRanges=editorRanges;this._highlightDescriptors=new Array(rawPositions.length);this._currentHighlight=undefined;this._firstToExecute=firstToExecute;this._currentSelection=undefined;this._sourceFrame=sourceFrame;};WebInspector.JavaScriptSourceFrame.StepIntoMarkup.prototype={show:function()
513 {var highlight=this._getVisibleHighlight();for(var i=0;i<this._positions.length;++i)
514 this._highlightItem(i,i===highlight);this._shownVisibleHighlight=highlight;},startIteratingSelection:function()
515 {this._currentSelection=this._positions.length
516 this._redrawHighlight();},stopIteratingSelection:function()
517 {this._currentSelection=undefined;this._redrawHighlight();},iterateSelection:function(backward)
518 {if(typeof this._currentSelection==="undefined")
519 return;var nextSelection=backward?this._currentSelection-1:this._currentSelection+1;var modulo=this._positions.length+1;nextSelection=(nextSelection+modulo)%modulo;this._currentSelection=nextSelection;this._redrawHighlight();},_redrawHighlight:function()
520 {var visibleHighlight=this._getVisibleHighlight();if(this._shownVisibleHighlight===visibleHighlight)
521 return;this._hideItemHighlight(this._shownVisibleHighlight);this._hideItemHighlight(visibleHighlight);this._highlightItem(this._shownVisibleHighlight,false);this._highlightItem(visibleHighlight,true);this._shownVisibleHighlight=visibleHighlight;},_getVisibleHighlight:function()
522 {return typeof this._currentSelection==="undefined"?this._firstToExecute:this._currentSelection;},_highlightItem:function(position,selected)
523 {if(position===this._positions.length)
524 return;var styleName=selected?"source-frame-stepin-mark-highlighted":"source-frame-stepin-mark";var textEditor=this._sourceFrame.textEditor;var highlightDescriptor=textEditor.highlightRange(this._editorRanges[position],styleName);this._highlightDescriptors[position]=highlightDescriptor;},_hideItemHighlight:function(position)
525 {if(position===this._positions.length)
526 return;var highlightDescriptor=this._highlightDescriptors[position];console.assert(highlightDescriptor);var textEditor=this._sourceFrame.textEditor;textEditor.removeHighlight(highlightDescriptor);this._highlightDescriptors[position]=undefined;},dispose:function()
527 {for(var i=0;i<this._positions.length;++i)
528 this._hideItemHighlight(i);},findItemByCoordinates:function(x,y)
529 {var textPosition=this._sourceFrame.textEditor.coordinatesToCursorPosition(x,y);if(!textPosition)
530 return;var ranges=this._editorRanges;for(var i=0;i<ranges.length;++i){var nextRange=ranges[i];if(nextRange.startLine==textPosition.startLine&&nextRange.startColumn<=textPosition.startColumn&&nextRange.endColumn>=textPosition.startColumn)
531 return i;}},getSelectedItemIndex:function()
532 {if(this._currentSelection===this._positions.length)
533 return undefined;return this._currentSelection;},getRawPosition:function(position)
534 {return(this._positions[position]);}};WebInspector.JavaScriptSourceFrame.StepIntoMarkup.create=function(sourceFrame,stepIntoRawLocations)
535 {if(!stepIntoRawLocations.length)
536 return null;var firstToExecute=stepIntoRawLocations[0];stepIntoRawLocations.sort(WebInspector.JavaScriptSourceFrame.StepIntoMarkup._Comparator);var firstToExecuteIndex=stepIntoRawLocations.indexOf(firstToExecute);var textEditor=sourceFrame.textEditor;var uiRanges=[];for(var i=0;i<stepIntoRawLocations.length;++i){var uiLocation=WebInspector.debuggerModel.rawLocationToUILocation((stepIntoRawLocations[i]));var token=textEditor.tokenAtTextPosition(uiLocation.lineNumber,uiLocation.columnNumber);var startColumn;var endColumn;if(token){startColumn=token.startColumn;endColumn=token.endColumn;}else{startColumn=uiLocation.columnNumber;endColumn=uiLocation.columnNumber;}
537 var range=new WebInspector.TextRange(uiLocation.lineNumber,startColumn,uiLocation.lineNumber,endColumn);uiRanges.push(range);}
538 return new WebInspector.JavaScriptSourceFrame.StepIntoMarkup(stepIntoRawLocations,uiRanges,firstToExecuteIndex,sourceFrame);};WebInspector.JavaScriptSourceFrame.StepIntoMarkup._Comparator=function(locationA,locationB)
539 {if(locationA.lineNumber===locationB.lineNumber)
540 return locationA.columnNumber-locationB.columnNumber;else
541 return locationA.lineNumber-locationB.lineNumber;};;WebInspector.CSSSourceFrame=function(uiSourceCode)
542 {WebInspector.UISourceCodeFrame.call(this,uiSourceCode);this._registerShortcuts();}
543 WebInspector.CSSSourceFrame.prototype={_registerShortcuts:function()
544 {var shortcutKeys=WebInspector.ShortcutsScreen.SourcesPanelShortcuts;for(var i=0;i<shortcutKeys.IncreaseCSSUnitByOne.length;++i)
545 this.addShortcut(shortcutKeys.IncreaseCSSUnitByOne[i].key,this._handleUnitModification.bind(this,1));for(var i=0;i<shortcutKeys.DecreaseCSSUnitByOne.length;++i)
546 this.addShortcut(shortcutKeys.DecreaseCSSUnitByOne[i].key,this._handleUnitModification.bind(this,-1));for(var i=0;i<shortcutKeys.IncreaseCSSUnitByTen.length;++i)
547 this.addShortcut(shortcutKeys.IncreaseCSSUnitByTen[i].key,this._handleUnitModification.bind(this,10));for(var i=0;i<shortcutKeys.DecreaseCSSUnitByTen.length;++i)
548 this.addShortcut(shortcutKeys.DecreaseCSSUnitByTen[i].key,this._handleUnitModification.bind(this,-10));},_modifyUnit:function(unit,change)
549 {var unitValue=parseInt(unit,10);if(isNaN(unitValue))
550 return null;var tail=unit.substring((unitValue).toString().length);return String.sprintf("%d%s",unitValue+change,tail);},_handleUnitModification:function(change)
551 {var selection=this.textEditor.selection().normalize();var token=this.textEditor.tokenAtTextPosition(selection.startLine,selection.startColumn);if(!token){if(selection.startColumn>0)
552 token=this.textEditor.tokenAtTextPosition(selection.startLine,selection.startColumn-1);if(!token)
553 return false;}
554 if(token.type!=="css-number")
555 return false;var cssUnitRange=new WebInspector.TextRange(selection.startLine,token.startColumn,selection.startLine,token.endColumn+1);var cssUnitText=this.textEditor.copyRange(cssUnitRange);var newUnitText=this._modifyUnit(cssUnitText,change);if(!newUnitText)
556 return false;this.textEditor.editRange(cssUnitRange,newUnitText);selection.startColumn=token.startColumn;selection.endColumn=selection.startColumn+newUnitText.length;this.textEditor.setSelection(selection);return true;},__proto__:WebInspector.UISourceCodeFrame.prototype};WebInspector.NavigatorOverlayController=function(parentSidebarView,navigatorView,editorView)
557 {this._parentSidebarView=parentSidebarView;this._navigatorView=navigatorView;this._editorView=editorView;this._navigatorSidebarResizeWidgetElement=this._navigatorView.element.createChild("div","resizer-widget");this._parentSidebarView.installResizer(this._navigatorSidebarResizeWidgetElement);this._navigatorShowHideButton=new WebInspector.StatusBarButton(WebInspector.UIString("Hide navigator"),"left-sidebar-show-hide-button scripts-navigator-show-hide-button",3);this._navigatorShowHideButton.state="left";this._navigatorShowHideButton.addEventListener("click",this._toggleNavigator,this);parentSidebarView.mainElement().appendChild(this._navigatorShowHideButton.element);WebInspector.settings.navigatorHidden=WebInspector.settings.createSetting("navigatorHidden",true);if(WebInspector.settings.navigatorHidden.get())
558 this._toggleNavigator();}
559 WebInspector.NavigatorOverlayController.prototype={wasShown:function()
560 {window.setTimeout(this._maybeShowNavigatorOverlay.bind(this),0);},_maybeShowNavigatorOverlay:function()
561 {if(WebInspector.settings.navigatorHidden.get()&&!WebInspector.settings.navigatorWasOnceHidden.get())
562 this.showNavigatorOverlay();},_toggleNavigator:function()
563 {if(this._navigatorShowHideButton.state==="overlay")
564 this._pinNavigator();else if(this._navigatorShowHideButton.state==="right")
565 this.showNavigatorOverlay();else
566 this._hidePinnedNavigator();},_hidePinnedNavigator:function()
567 {this._navigatorShowHideButton.state="right";this._navigatorShowHideButton.title=WebInspector.UIString("Show navigator");this._parentSidebarView.element.appendChild(this._navigatorShowHideButton.element);this._editorView.element.classList.add("navigator-hidden");this._navigatorSidebarResizeWidgetElement.classList.add("hidden");this._parentSidebarView.hideSidebarElement();this._navigatorView.detach();this._editorView.focus();WebInspector.settings.navigatorWasOnceHidden.set(true);WebInspector.settings.navigatorHidden.set(true);},_pinNavigator:function()
568 {this._navigatorShowHideButton.state="left";this._navigatorShowHideButton.title=WebInspector.UIString("Hide navigator");this._editorView.element.classList.remove("navigator-hidden");this._navigatorSidebarResizeWidgetElement.classList.remove("hidden");this._editorView.element.appendChild(this._navigatorShowHideButton.element);this._innerHideNavigatorOverlay();this._parentSidebarView.showSidebarElement();this._parentSidebarView.setSidebarView(this._navigatorView);this._navigatorView.focus();WebInspector.settings.navigatorHidden.set(false);},showNavigatorOverlay:function()
569 {if(this._navigatorShowHideButton.state==="overlay")
570 return;this._navigatorShowHideButton.state="overlay";this._navigatorShowHideButton.title=WebInspector.UIString("Pin navigator");this._sidebarOverlay=new WebInspector.SidebarOverlay(this._navigatorView,"scriptsPanelNavigatorOverlayWidth",Preferences.minScriptsSidebarWidth);this._boundKeyDown=this._keyDown.bind(this);this._sidebarOverlay.element.addEventListener("keydown",this._boundKeyDown,false);var navigatorOverlayResizeWidgetElement=document.createElement("div");navigatorOverlayResizeWidgetElement.classList.add("resizer-widget");this._sidebarOverlay.resizerWidgetElement=navigatorOverlayResizeWidgetElement;this._navigatorView.element.appendChild(this._navigatorShowHideButton.element);this._boundContainingElementFocused=this._containingElementFocused.bind(this);this._parentSidebarView.element.addEventListener("mousedown",this._boundContainingElementFocused,false);this._sidebarOverlay.show(this._parentSidebarView.element);this._navigatorView.focus();},_keyDown:function(event)
571 {if(event.handled)
572 return;if(event.keyCode===WebInspector.KeyboardShortcut.Keys.Esc.code){this.hideNavigatorOverlay();event.consume(true);}},hideNavigatorOverlay:function()
573 {if(this._navigatorShowHideButton.state!=="overlay")
574 return;this._navigatorShowHideButton.state="right";this._navigatorShowHideButton.title=WebInspector.UIString("Show navigator");this._parentSidebarView.element.appendChild(this._navigatorShowHideButton.element);this._innerHideNavigatorOverlay();this._editorView.focus();},_innerHideNavigatorOverlay:function()
575 {this._parentSidebarView.element.removeEventListener("mousedown",this._boundContainingElementFocused,false);this._sidebarOverlay.element.removeEventListener("keydown",this._boundKeyDown,false);this._sidebarOverlay.hide();},_containingElementFocused:function(event)
576 {if(!event.target.isSelfOrDescendant(this._sidebarOverlay.element))
577 this.hideNavigatorOverlay();},isNavigatorPinned:function()
578 {return this._navigatorShowHideButton.state==="left";},isNavigatorHidden:function()
579 {return this._navigatorShowHideButton.state==="right";}};WebInspector.NavigatorView=function()
580 {WebInspector.View.call(this);this.registerRequiredCSS("navigatorView.css");var scriptsTreeElement=document.createElement("ol");this._scriptsTree=new WebInspector.NavigatorTreeOutline(scriptsTreeElement);this._scriptsTree.childrenListElement.addEventListener("keypress",this._treeKeyPress.bind(this),true);var scriptsOutlineElement=document.createElement("div");scriptsOutlineElement.classList.add("outline-disclosure");scriptsOutlineElement.classList.add("navigator");scriptsOutlineElement.appendChild(scriptsTreeElement);this.element.classList.add("fill");this.element.classList.add("navigator-container");this.element.appendChild(scriptsOutlineElement);this.setDefaultFocusedElement(this._scriptsTree.element);this._uiSourceCodeNodes=new Map();this._subfolderNodes=new Map();this._rootNode=new WebInspector.NavigatorRootTreeNode(this);this._rootNode.populate();WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged,this._inspectedURLChanged,this);this.element.addEventListener("contextmenu",this.handleContextMenu.bind(this),false);}
581 WebInspector.NavigatorView.Events={ItemSelected:"ItemSelected",ItemSearchStarted:"ItemSearchStarted",ItemRenamingRequested:"ItemRenamingRequested",ItemCreationRequested:"ItemCreationRequested"}
582 WebInspector.NavigatorView.iconClassForType=function(type)
583 {if(type===WebInspector.NavigatorTreeOutline.Types.Domain)
584 return"navigator-domain-tree-item";if(type===WebInspector.NavigatorTreeOutline.Types.FileSystem)
585 return"navigator-folder-tree-item";return"navigator-folder-tree-item";}
586 WebInspector.NavigatorView.prototype={addUISourceCode:function(uiSourceCode)
587 {var projectNode=this._projectNode(uiSourceCode.project());var folderNode=this._folderNode(projectNode,uiSourceCode.parentPath());var uiSourceCodeNode=new WebInspector.NavigatorUISourceCodeTreeNode(this,uiSourceCode);this._uiSourceCodeNodes.put(uiSourceCode,uiSourceCodeNode);folderNode.appendChild(uiSourceCodeNode);if(uiSourceCode.url===WebInspector.inspectedPageURL)
588 this.revealUISourceCode(uiSourceCode);},_inspectedURLChanged:function(event)
589 {var nodes=this._uiSourceCodeNodes.values();for(var i=0;i<nodes.length;++i){var uiSourceCode=nodes[i].uiSourceCode();if(uiSourceCode.url===WebInspector.inspectedPageURL)
590 this.revealUISourceCode(uiSourceCode);}},_projectNode:function(project)
591 {if(!project.displayName())
592 return this._rootNode;var projectNode=this._rootNode.child(project.id());if(!projectNode){var type=project.type()===WebInspector.projectTypes.FileSystem?WebInspector.NavigatorTreeOutline.Types.FileSystem:WebInspector.NavigatorTreeOutline.Types.Domain;projectNode=new WebInspector.NavigatorFolderTreeNode(this,project,project.id(),type,"",project.displayName());this._rootNode.appendChild(projectNode);}
593 return projectNode;},_folderNode:function(projectNode,folderPath)
594 {if(!folderPath)
595 return projectNode;var subfolderNodes=this._subfolderNodes.get(projectNode);if(!subfolderNodes){subfolderNodes=(new StringMap());this._subfolderNodes.put(projectNode,subfolderNodes);}
596 var folderNode=subfolderNodes.get(folderPath);if(folderNode)
597 return folderNode;var parentNode=projectNode;var index=folderPath.lastIndexOf("/");if(index!==-1)
598 parentNode=this._folderNode(projectNode,folderPath.substring(0,index));var name=folderPath.substring(index+1);folderNode=new WebInspector.NavigatorFolderTreeNode(this,null,name,WebInspector.NavigatorTreeOutline.Types.Folder,folderPath,name);subfolderNodes.put(folderPath,folderNode);parentNode.appendChild(folderNode);return folderNode;},revealUISourceCode:function(uiSourceCode,select)
599 {var node=this._uiSourceCodeNodes.get(uiSourceCode);if(!node)
600 return;if(this._scriptsTree.selectedTreeElement)
601 this._scriptsTree.selectedTreeElement.deselect();this._lastSelectedUISourceCode=uiSourceCode;node.reveal(select);},_sourceSelected:function(uiSourceCode,focusSource)
602 {this._lastSelectedUISourceCode=uiSourceCode;var data={uiSourceCode:uiSourceCode,focusSource:focusSource};this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemSelected,data);},sourceDeleted:function(uiSourceCode)
603 {},removeUISourceCode:function(uiSourceCode)
604 {var node=this._uiSourceCodeNodes.get(uiSourceCode);if(!node)
605 return;var projectNode=this._projectNode(uiSourceCode.project());var subfolderNodes=this._subfolderNodes.get(projectNode);var parentNode=node.parent;this._uiSourceCodeNodes.remove(uiSourceCode);parentNode.removeChild(node);node=parentNode;while(node){parentNode=node.parent;if(!parentNode||!node.isEmpty())
606 break;if(subfolderNodes)
607 subfolderNodes.remove(node._folderPath);parentNode.removeChild(node);node=parentNode;}},updateIcon:function(uiSourceCode)
608 {var node=this._uiSourceCodeNodes.get(uiSourceCode);node.updateIcon();},requestRename:function(uiSourceCode)
609 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.ItemRenamingRequested,uiSourceCode);},rename:function(uiSourceCode,callback)
610 {var node=this._uiSourceCodeNodes.get(uiSourceCode);if(!node)
611 return;node.rename(callback);},reset:function()
612 {var nodes=this._uiSourceCodeNodes.values();for(var i=0;i<nodes.length;++i)
613 nodes[i].dispose();this._scriptsTree.removeChildren();this._uiSourceCodeNodes.clear();this._subfolderNodes.clear();this._rootNode.reset();},handleContextMenu:function(event)
614 {var contextMenu=new WebInspector.ContextMenu(event);this._appendAddFolderItem(contextMenu);contextMenu.show();},_appendAddFolderItem:function(contextMenu)
615 {function addFolder()
616 {WebInspector.isolatedFileSystemManager.addFileSystem();}
617 var addFolderLabel=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add folder to workspace":"Add Folder to Workspace");contextMenu.appendItem(addFolderLabel,addFolder);},_handleContextMenuRefresh:function(project,path)
618 {project.refresh(path);},_handleContextMenuCreate:function(project,path,uiSourceCode)
619 {var data={};data.project=project;data.path=path;data.uiSourceCode=uiSourceCode;this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemCreationRequested,data);},_handleContextMenuExclude:function(project,path)
620 {var shouldExclude=window.confirm(WebInspector.UIString("Are you sure you want to exclude this folder?"));if(shouldExclude){WebInspector.startBatchUpdate();project.excludeFolder(path);WebInspector.endBatchUpdate();}},_handleContextMenuDelete:function(uiSourceCode)
621 {var shouldDelete=window.confirm(WebInspector.UIString("Are you sure you want to delete this file?"));if(shouldDelete)
622 uiSourceCode.project().deleteFile(uiSourceCode.path());},handleFileContextMenu:function(event,uiSourceCode)
623 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendApplicableItems(uiSourceCode);contextMenu.appendSeparator();var project=uiSourceCode.project();var path=uiSourceCode.parentPath();contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Refresh parent":"Refresh Parent"),this._handleContextMenuRefresh.bind(this,project,path));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Duplicate file":"Duplicate File"),this._handleContextMenuCreate.bind(this,project,path,uiSourceCode));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Exclude parent folder":"Exclude Parent Folder"),this._handleContextMenuExclude.bind(this,project,path));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Delete file":"Delete File"),this._handleContextMenuDelete.bind(this,uiSourceCode));contextMenu.appendSeparator();this._appendAddFolderItem(contextMenu);contextMenu.show();},handleFolderContextMenu:function(event,node)
624 {var contextMenu=new WebInspector.ContextMenu(event);var path="/";var projectNode=node;while(projectNode.parent!==this._rootNode){path="/"+projectNode.id+path;projectNode=projectNode.parent;}
625 var project=projectNode._project;if(project.type()===WebInspector.projectTypes.FileSystem){contextMenu.appendItem(WebInspector.UIString("Refresh"),this._handleContextMenuRefresh.bind(this,project,path));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"New file":"New File"),this._handleContextMenuCreate.bind(this,project,path));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Exclude folder":"Exclude Folder"),this._handleContextMenuExclude.bind(this,project,path));}
626 contextMenu.appendSeparator();this._appendAddFolderItem(contextMenu);function removeFolder()
627 {var shouldRemove=window.confirm(WebInspector.UIString("Are you sure you want to remove this folder?"));if(shouldRemove)
628 project.remove();}
629 if(project.type()===WebInspector.projectTypes.FileSystem&&node===projectNode){var removeFolderLabel=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove folder from workspace":"Remove Folder from Workspace");contextMenu.appendItem(removeFolderLabel,removeFolder);}
630 contextMenu.show();},_treeKeyPress:function(event)
631 {if(WebInspector.isBeingEdited(this._scriptsTree.childrenListElement))
632 return;var searchText=String.fromCharCode(event.charCode);if(searchText.trim()!==searchText)
633 return;this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemSearchStarted,searchText);event.consume(true);},__proto__:WebInspector.View.prototype}
634 WebInspector.NavigatorTreeOutline=function(element)
635 {TreeOutline.call(this,element);this.element=element;this.comparator=WebInspector.NavigatorTreeOutline._treeElementsCompare;}
636 WebInspector.NavigatorTreeOutline.Types={Root:"Root",Domain:"Domain",Folder:"Folder",UISourceCode:"UISourceCode",FileSystem:"FileSystem"}
637 WebInspector.NavigatorTreeOutline._treeElementsCompare=function compare(treeElement1,treeElement2)
638 {function typeWeight(treeElement)
639 {var type=treeElement.type();if(type===WebInspector.NavigatorTreeOutline.Types.Domain){if(treeElement.titleText===WebInspector.inspectedPageDomain)
640 return 1;return 2;}
641 if(type===WebInspector.NavigatorTreeOutline.Types.FileSystem)
642 return 3;if(type===WebInspector.NavigatorTreeOutline.Types.Folder)
643 return 4;return 5;}
644 var typeWeight1=typeWeight(treeElement1);var typeWeight2=typeWeight(treeElement2);var result;if(typeWeight1>typeWeight2)
645 result=1;else if(typeWeight1<typeWeight2)
646 result=-1;else{var title1=treeElement1.titleText;var title2=treeElement2.titleText;result=title1.compareTo(title2);}
647 return result;}
648 WebInspector.NavigatorTreeOutline.prototype={scriptTreeElements:function()
649 {var result=[];if(this.children.length){for(var treeElement=this.children[0];treeElement;treeElement=treeElement.traverseNextTreeElement(false,this,true)){if(treeElement instanceof WebInspector.NavigatorSourceTreeElement)
650 result.push(treeElement.uiSourceCode);}}
651 return result;},__proto__:TreeOutline.prototype}
652 WebInspector.BaseNavigatorTreeElement=function(type,title,iconClasses,hasChildren,noIcon)
653 {this._type=type;TreeElement.call(this,"",null,hasChildren);this._titleText=title;this._iconClasses=iconClasses;this._noIcon=noIcon;}
654 WebInspector.BaseNavigatorTreeElement.prototype={onattach:function()
655 {this.listItemElement.removeChildren();if(this._iconClasses){for(var i=0;i<this._iconClasses.length;++i)
656 this.listItemElement.classList.add(this._iconClasses[i]);}
657 var selectionElement=document.createElement("div");selectionElement.className="selection";this.listItemElement.appendChild(selectionElement);if(!this._noIcon){this.imageElement=document.createElement("img");this.imageElement.className="icon";this.listItemElement.appendChild(this.imageElement);}
658 this.titleElement=document.createElement("div");this.titleElement.className="base-navigator-tree-element-title";this._titleTextNode=document.createTextNode("");this._titleTextNode.textContent=this._titleText;this.titleElement.appendChild(this._titleTextNode);this.listItemElement.appendChild(this.titleElement);},updateIconClasses:function(iconClasses)
659 {for(var i=0;i<this._iconClasses.length;++i)
660 this.listItemElement.classList.remove(this._iconClasses[i]);this._iconClasses=iconClasses;for(var i=0;i<this._iconClasses.length;++i)
661 this.listItemElement.classList.add(this._iconClasses[i]);},onreveal:function()
662 {if(this.listItemElement)
663 this.listItemElement.scrollIntoViewIfNeeded(true);},get titleText()
664 {return this._titleText;},set titleText(titleText)
665 {if(this._titleText===titleText)
666 return;this._titleText=titleText||"";if(this.titleElement)
667 this.titleElement.textContent=this._titleText;},type:function()
668 {return this._type;},__proto__:TreeElement.prototype}
669 WebInspector.NavigatorFolderTreeElement=function(navigatorView,type,title)
670 {var iconClass=WebInspector.NavigatorView.iconClassForType(type);WebInspector.BaseNavigatorTreeElement.call(this,type,title,[iconClass],true);this._navigatorView=navigatorView;}
671 WebInspector.NavigatorFolderTreeElement.prototype={onpopulate:function()
672 {this._node.populate();},onattach:function()
673 {WebInspector.BaseNavigatorTreeElement.prototype.onattach.call(this);this.collapse();this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),false);},setNode:function(node)
674 {this._node=node;var paths=[];while(node&&!node.isRoot()){paths.push(node._title);node=node.parent;}
675 paths.reverse();this.tooltip=paths.join("/");},_handleContextMenuEvent:function(event)
676 {if(!this._node)
677 return;this.select();this._navigatorView.handleFolderContextMenu((event),this._node);},__proto__:WebInspector.BaseNavigatorTreeElement.prototype}
678 WebInspector.NavigatorSourceTreeElement=function(navigatorView,uiSourceCode,title)
679 {this._navigatorView=navigatorView;this._uiSourceCode=uiSourceCode;WebInspector.BaseNavigatorTreeElement.call(this,WebInspector.NavigatorTreeOutline.Types.UISourceCode,title,this._calculateIconClasses(),false);this.tooltip=uiSourceCode.originURL();}
680 WebInspector.NavigatorSourceTreeElement.prototype={get uiSourceCode()
681 {return this._uiSourceCode;},_calculateIconClasses:function()
682 {return["navigator-"+this._uiSourceCode.contentType().name()+"-tree-item"];},updateIcon:function()
683 {this.updateIconClasses(this._calculateIconClasses());},onattach:function()
684 {WebInspector.BaseNavigatorTreeElement.prototype.onattach.call(this);this.listItemElement.draggable=true;this.listItemElement.addEventListener("click",this._onclick.bind(this),false);this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),false);this.listItemElement.addEventListener("mousedown",this._onmousedown.bind(this),false);this.listItemElement.addEventListener("dragstart",this._ondragstart.bind(this),false);},_onmousedown:function(event)
685 {if(event.which===1)
686 this._uiSourceCode.requestContent(callback.bind(this));function callback(content)
687 {this._warmedUpContent=content;}},_shouldRenameOnMouseDown:function()
688 {if(!this._uiSourceCode.canRename())
689 return false;var isSelected=this===this.treeOutline.selectedTreeElement;var isFocused=this.treeOutline.childrenListElement.isSelfOrAncestor(document.activeElement);return isSelected&&isFocused&&!WebInspector.isBeingEdited(this.treeOutline.element);},selectOnMouseDown:function(event)
690 {if(event.which!==1||!this._shouldRenameOnMouseDown()){TreeElement.prototype.selectOnMouseDown.call(this,event);return;}
691 setTimeout(rename.bind(this),300);function rename()
692 {if(this._shouldRenameOnMouseDown())
693 this._navigatorView.requestRename(this._uiSourceCode);}},_ondragstart:function(event)
694 {event.dataTransfer.setData("text/plain",this._warmedUpContent);event.dataTransfer.effectAllowed="copy";return true;},onspace:function()
695 {this._navigatorView._sourceSelected(this.uiSourceCode,true);return true;},_onclick:function(event)
696 {this._navigatorView._sourceSelected(this.uiSourceCode,false);},ondblclick:function(event)
697 {var middleClick=event.button===1;this._navigatorView._sourceSelected(this.uiSourceCode,!middleClick);return false;},onenter:function()
698 {this._navigatorView._sourceSelected(this.uiSourceCode,true);return true;},ondelete:function()
699 {this._navigatorView.sourceDeleted(this.uiSourceCode);return true;},_handleContextMenuEvent:function(event)
700 {this.select();this._navigatorView.handleFileContextMenu(event,this._uiSourceCode);},__proto__:WebInspector.BaseNavigatorTreeElement.prototype}
701 WebInspector.NavigatorTreeNode=function(id)
702 {this.id=id;this._children=new StringMap();}
703 WebInspector.NavigatorTreeNode.prototype={treeElement:function(){},dispose:function(){},isRoot:function()
704 {return false;},hasChildren:function()
705 {return true;},populate:function()
706 {if(this.isPopulated())
707 return;if(this.parent)
708 this.parent.populate();this._populated=true;this.wasPopulated();},wasPopulated:function()
709 {var children=this.children();for(var i=0;i<children.length;++i)
710 this.treeElement().appendChild(children[i].treeElement());},didAddChild:function(node)
711 {if(this.isPopulated())
712 this.treeElement().appendChild(node.treeElement());},willRemoveChild:function(node)
713 {if(this.isPopulated())
714 this.treeElement().removeChild(node.treeElement());},isPopulated:function()
715 {return this._populated;},isEmpty:function()
716 {return!this._children.size();},child:function(id)
717 {return this._children.get(id)||null;},children:function()
718 {return this._children.values();},appendChild:function(node)
719 {this._children.put(node.id,node);node.parent=this;this.didAddChild(node);},removeChild:function(node)
720 {this.willRemoveChild(node);this._children.remove(node.id);delete node.parent;node.dispose();},reset:function()
721 {this._children.clear();}}
722 WebInspector.NavigatorRootTreeNode=function(navigatorView)
723 {WebInspector.NavigatorTreeNode.call(this,"");this._navigatorView=navigatorView;}
724 WebInspector.NavigatorRootTreeNode.prototype={isRoot:function()
725 {return true;},treeElement:function()
726 {return this._navigatorView._scriptsTree;},__proto__:WebInspector.NavigatorTreeNode.prototype}
727 WebInspector.NavigatorUISourceCodeTreeNode=function(navigatorView,uiSourceCode)
728 {WebInspector.NavigatorTreeNode.call(this,uiSourceCode.name());this._navigatorView=navigatorView;this._uiSourceCode=uiSourceCode;this._treeElement=null;}
729 WebInspector.NavigatorUISourceCodeTreeNode.prototype={uiSourceCode:function()
730 {return this._uiSourceCode;},updateIcon:function()
731 {if(this._treeElement)
732 this._treeElement.updateIcon();},treeElement:function()
733 {if(this._treeElement)
734 return this._treeElement;this._treeElement=new WebInspector.NavigatorSourceTreeElement(this._navigatorView,this._uiSourceCode,"");this.updateTitle();this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged,this._titleChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._workingCopyChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._workingCopyCommitted,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged,this._formattedChanged,this);return this._treeElement;},updateTitle:function(ignoreIsDirty)
735 {if(!this._treeElement)
736 return;var titleText=this._uiSourceCode.displayName();if(!ignoreIsDirty&&(this._uiSourceCode.isDirty()||this._uiSourceCode.hasUnsavedCommittedChanges()))
737 titleText="*"+titleText;this._treeElement.titleText=titleText;},hasChildren:function()
738 {return false;},dispose:function()
739 {if(!this._treeElement)
740 return;this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged,this._titleChanged,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._workingCopyChanged,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._workingCopyCommitted,this);this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged,this._formattedChanged,this);},_titleChanged:function(event)
741 {this.updateTitle();},_workingCopyChanged:function(event)
742 {this.updateTitle();},_workingCopyCommitted:function(event)
743 {this.updateTitle();},_formattedChanged:function(event)
744 {this.updateTitle();},reveal:function(select)
745 {this.parent.populate();this.parent.treeElement().expand();this._treeElement.reveal();if(select)
746 this._treeElement.select();},rename:function(callback)
747 {if(!this._treeElement)
748 return;var treeOutlineElement=this._treeElement.treeOutline.element;WebInspector.markBeingEdited(treeOutlineElement,true);function commitHandler(element,newTitle,oldTitle)
749 {if(newTitle!==oldTitle){this._treeElement.titleText=newTitle;this._uiSourceCode.rename(newTitle,renameCallback.bind(this));return;}
750 afterEditing.call(this,true);}
751 function renameCallback(success)
752 {if(!success){WebInspector.markBeingEdited(treeOutlineElement,false);this.updateTitle();this.rename(callback);return;}
753 afterEditing.call(this,true);}
754 function cancelHandler()
755 {afterEditing.call(this,false);}
756 function afterEditing(committed)
757 {WebInspector.markBeingEdited(treeOutlineElement,false);this.updateTitle();this._treeElement.treeOutline.childrenListElement.focus();if(callback)
758 callback(committed);}
759 var editingConfig=new WebInspector.EditingConfig(commitHandler.bind(this),cancelHandler.bind(this));this.updateTitle(true);WebInspector.startEditing(this._treeElement.titleElement,editingConfig);window.getSelection().setBaseAndExtent(this._treeElement.titleElement,0,this._treeElement.titleElement,1);},__proto__:WebInspector.NavigatorTreeNode.prototype}
760 WebInspector.NavigatorFolderTreeNode=function(navigatorView,project,id,type,folderPath,title)
761 {WebInspector.NavigatorTreeNode.call(this,id);this._navigatorView=navigatorView;this._project=project;this._type=type;this._folderPath=folderPath;this._title=title;}
762 WebInspector.NavigatorFolderTreeNode.prototype={treeElement:function()
763 {if(this._treeElement)
764 return this._treeElement;this._treeElement=this._createTreeElement(this._title,this);return this._treeElement;},_createTreeElement:function(title,node)
765 {var treeElement=new WebInspector.NavigatorFolderTreeElement(this._navigatorView,this._type,title);treeElement.setNode(node);return treeElement;},wasPopulated:function()
766 {if(!this._treeElement||this._treeElement._node!==this)
767 return;this._addChildrenRecursive();},_addChildrenRecursive:function()
768 {var children=this.children();for(var i=0;i<children.length;++i){var child=children[i];this.didAddChild(child);if(child instanceof WebInspector.NavigatorFolderTreeNode)
769 child._addChildrenRecursive();}},_shouldMerge:function(node)
770 {return this._type!==WebInspector.NavigatorTreeOutline.Types.Domain&&node instanceof WebInspector.NavigatorFolderTreeNode;},didAddChild:function(node)
771 {function titleForNode(node)
772 {return node._title;}
773 if(!this._treeElement)
774 return;var children=this.children();if(children.length===1&&this._shouldMerge(node)){node._isMerged=true;this._treeElement.titleText=this._treeElement.titleText+"/"+node._title;node._treeElement=this._treeElement;this._treeElement.setNode(node);return;}
775 var oldNode;if(children.length===2)
776 oldNode=children[0]!==node?children[0]:children[1];if(oldNode&&oldNode._isMerged){delete oldNode._isMerged;var mergedToNodes=[];mergedToNodes.push(this);var treeNode=this;while(treeNode._isMerged){treeNode=treeNode.parent;mergedToNodes.push(treeNode);}
777 mergedToNodes.reverse();var titleText=mergedToNodes.map(titleForNode).join("/");var nodes=[];treeNode=oldNode;do{nodes.push(treeNode);children=treeNode.children();treeNode=children.length===1?children[0]:null;}while(treeNode&&treeNode._isMerged);if(!this.isPopulated()){this._treeElement.titleText=titleText;this._treeElement.setNode(this);for(var i=0;i<nodes.length;++i){delete nodes[i]._treeElement;delete nodes[i]._isMerged;}
778 return;}
779 var oldTreeElement=this._treeElement;var treeElement=this._createTreeElement(titleText,this);for(var i=0;i<mergedToNodes.length;++i)
780 mergedToNodes[i]._treeElement=treeElement;oldTreeElement.parent.appendChild(treeElement);oldTreeElement.setNode(nodes[nodes.length-1]);oldTreeElement.titleText=nodes.map(titleForNode).join("/");oldTreeElement.parent.removeChild(oldTreeElement);this._treeElement.appendChild(oldTreeElement);if(oldTreeElement.expanded)
781 treeElement.expand();}
782 if(this.isPopulated())
783 this._treeElement.appendChild(node.treeElement());},willRemoveChild:function(node)
784 {if(node._isMerged||!this.isPopulated())
785 return;this._treeElement.removeChild(node._treeElement);},__proto__:WebInspector.NavigatorTreeNode.prototype};WebInspector.RevisionHistoryView=function()
786 {WebInspector.View.call(this);this.registerRequiredCSS("revisionHistory.css");this.element.classList.add("revision-history-drawer");this.element.classList.add("fill");this.element.classList.add("outline-disclosure");this._uiSourceCodeItems=new Map();var olElement=this.element.createChild("ol");this._treeOutline=new TreeOutline(olElement);function populateRevisions(uiSourceCode)
787 {if(uiSourceCode.history.length)
788 this._createUISourceCodeItem(uiSourceCode);}
789 WebInspector.workspace.uiSourceCodes().forEach(populateRevisions.bind(this));WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeContentCommitted,this._revisionAdded,this);WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved,this._uiSourceCodeRemoved,this);WebInspector.workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset,this._projectWillReset,this);}
790 WebInspector.RevisionHistoryView.showHistory=function(uiSourceCode)
791 {if(!WebInspector.RevisionHistoryView._view)
792 WebInspector.RevisionHistoryView._view=new WebInspector.RevisionHistoryView();var view=WebInspector.RevisionHistoryView._view;WebInspector.inspectorView.showCloseableViewInDrawer("history",WebInspector.UIString("History"),view);view._revealUISourceCode(uiSourceCode);}
793 WebInspector.RevisionHistoryView.prototype={_createUISourceCodeItem:function(uiSourceCode)
794 {var uiSourceCodeItem=new TreeElement(uiSourceCode.displayName(),null,true);uiSourceCodeItem.selectable=false;for(var i=0;i<this._treeOutline.children.length;++i){if(this._treeOutline.children[i].title.localeCompare(uiSourceCode.displayName())>0){this._treeOutline.insertChild(uiSourceCodeItem,i);break;}}
795 if(i===this._treeOutline.children.length)
796 this._treeOutline.appendChild(uiSourceCodeItem);this._uiSourceCodeItems.put(uiSourceCode,uiSourceCodeItem);var revisionCount=uiSourceCode.history.length;for(var i=revisionCount-1;i>=0;--i){var revision=uiSourceCode.history[i];var historyItem=new WebInspector.RevisionHistoryTreeElement(revision,uiSourceCode.history[i-1],i!==revisionCount-1);uiSourceCodeItem.appendChild(historyItem);}
797 var linkItem=new TreeElement("",null,false);linkItem.selectable=false;uiSourceCodeItem.appendChild(linkItem);var revertToOriginal=linkItem.listItemElement.createChild("span","revision-history-link revision-history-link-row");revertToOriginal.textContent=WebInspector.UIString("apply original content");revertToOriginal.addEventListener("click",uiSourceCode.revertToOriginal.bind(uiSourceCode));var clearHistoryElement=uiSourceCodeItem.listItemElement.createChild("span","revision-history-link");clearHistoryElement.textContent=WebInspector.UIString("revert");clearHistoryElement.addEventListener("click",this._clearHistory.bind(this,uiSourceCode));return uiSourceCodeItem;},_clearHistory:function(uiSourceCode)
798 {uiSourceCode.revertAndClearHistory(this._removeUISourceCode.bind(this));},_revisionAdded:function(event)
799 {var uiSourceCode=(event.data.uiSourceCode);var uiSourceCodeItem=this._uiSourceCodeItems.get(uiSourceCode);if(!uiSourceCodeItem){uiSourceCodeItem=this._createUISourceCodeItem(uiSourceCode);return;}
800 var historyLength=uiSourceCode.history.length;var historyItem=new WebInspector.RevisionHistoryTreeElement(uiSourceCode.history[historyLength-1],uiSourceCode.history[historyLength-2],false);if(uiSourceCodeItem.children.length)
801 uiSourceCodeItem.children[0].allowRevert();uiSourceCodeItem.insertChild(historyItem,0);},_revealUISourceCode:function(uiSourceCode)
802 {var uiSourceCodeItem=this._uiSourceCodeItems.get(uiSourceCode);if(uiSourceCodeItem){uiSourceCodeItem.reveal();uiSourceCodeItem.expand();}},_uiSourceCodeRemoved:function(event)
803 {var uiSourceCode=(event.data);this._removeUISourceCode(uiSourceCode);},_removeUISourceCode:function(uiSourceCode)
804 {var uiSourceCodeItem=this._uiSourceCodeItems.get(uiSourceCode);if(!uiSourceCodeItem)
805 return;this._treeOutline.removeChild(uiSourceCodeItem);this._uiSourceCodeItems.remove(uiSourceCode);},_projectWillReset:function(event)
806 {var project=event.data;project.uiSourceCodes().forEach(this._removeUISourceCode.bind(this));},__proto__:WebInspector.View.prototype}
807 WebInspector.RevisionHistoryTreeElement=function(revision,baseRevision,allowRevert)
808 {TreeElement.call(this,revision.timestamp.toLocaleTimeString(),null,true);this.selectable=false;this._revision=revision;this._baseRevision=baseRevision;this._revertElement=document.createElement("span");this._revertElement.className="revision-history-link";this._revertElement.textContent=WebInspector.UIString("apply revision content");this._revertElement.addEventListener("click",this._revision.revertToThis.bind(this._revision),false);if(!allowRevert)
809 this._revertElement.classList.add("hidden");}
810 WebInspector.RevisionHistoryTreeElement.prototype={onattach:function()
811 {this.listItemElement.classList.add("revision-history-revision");},onexpand:function()
812 {this.listItemElement.appendChild(this._revertElement);if(this._wasExpandedOnce)
813 return;this._wasExpandedOnce=true;this.childrenListElement.classList.add("source-code");if(this._baseRevision)
814 this._baseRevision.requestContent(step1.bind(this));else
815 this._revision.uiSourceCode.requestOriginalContent(step1.bind(this));function step1(baseContent)
816 {this._revision.requestContent(step2.bind(this,baseContent));}
817 function step2(baseContent,newContent)
818 {var baseLines=difflib.stringAsLines(baseContent);var newLines=difflib.stringAsLines(newContent);var sm=new difflib.SequenceMatcher(baseLines,newLines);var opcodes=sm.get_opcodes();var lastWasSeparator=false;for(var idx=0;idx<opcodes.length;idx++){var code=opcodes[idx];var change=code[0];var b=code[1];var be=code[2];var n=code[3];var ne=code[4];var rowCount=Math.max(be-b,ne-n);var topRows=[];var bottomRows=[];for(var i=0;i<rowCount;i++){if(change==="delete"||(change==="replace"&&b<be)){var lineNumber=b++;this._createLine(lineNumber,null,baseLines[lineNumber],"removed");lastWasSeparator=false;}
819 if(change==="insert"||(change==="replace"&&n<ne)){var lineNumber=n++;this._createLine(null,lineNumber,newLines[lineNumber],"added");lastWasSeparator=false;}
820 if(change==="equal"){b++;n++;if(!lastWasSeparator)
821 this._createLine(null,null,"    \u2026","separator");lastWasSeparator=true;}}}}},oncollapse:function()
822 {this._revertElement.remove();},_createLine:function(baseLineNumber,newLineNumber,lineContent,changeType)
823 {var child=new TreeElement("",null,false);child.selectable=false;this.appendChild(child);var lineElement=document.createElement("span");function appendLineNumber(lineNumber)
824 {var numberString=lineNumber!==null?numberToStringWithSpacesPadding(lineNumber+1,4):"    ";var lineNumberSpan=document.createElement("span");lineNumberSpan.classList.add("webkit-line-number");lineNumberSpan.textContent=numberString;child.listItemElement.appendChild(lineNumberSpan);}
825 appendLineNumber(baseLineNumber);appendLineNumber(newLineNumber);var contentSpan=document.createElement("span");contentSpan.textContent=lineContent;child.listItemElement.appendChild(contentSpan);child.listItemElement.classList.add("revision-history-line");child.listItemElement.classList.add("revision-history-line-"+changeType);},allowRevert:function()
826 {this._revertElement.classList.remove("hidden");},__proto__:TreeElement.prototype};WebInspector.ScopeChainSidebarPane=function()
827 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Scope Variables"));this._sections=[];this._expandedSections={};this._expandedProperties=[];}
828 WebInspector.ScopeChainSidebarPane.prototype={update:function(callFrame)
829 {this.bodyElement.removeChildren();if(!callFrame){var infoElement=document.createElement("div");infoElement.className="info";infoElement.textContent=WebInspector.UIString("Not Paused");this.bodyElement.appendChild(infoElement);return;}
830 for(var i=0;i<this._sections.length;++i){var section=this._sections[i];if(!section.title)
831 continue;if(section.expanded)
832 this._expandedSections[section.title]=true;else
833 delete this._expandedSections[section.title];}
834 this._sections=[];var foundLocalScope=false;var scopeChain=callFrame.scopeChain;for(var i=0;i<scopeChain.length;++i){var scope=scopeChain[i];var title=null;var subtitle=scope.object.description;var emptyPlaceholder=null;var extraProperties=[];var declarativeScope;switch(scope.type){case DebuggerAgent.ScopeType.Local:foundLocalScope=true;title=WebInspector.UIString("Local");emptyPlaceholder=WebInspector.UIString("No Variables");subtitle=undefined;if(callFrame.this)
835 extraProperties.push(new WebInspector.RemoteObjectProperty("this",WebInspector.RemoteObject.fromPayload(callFrame.this)));if(i==0){var details=WebInspector.debuggerModel.debuggerPausedDetails();var exception=details.reason===WebInspector.DebuggerModel.BreakReason.Exception?details.auxData:0;if(exception){var exceptionObject=(exception);extraProperties.push(new WebInspector.RemoteObjectProperty("<exception>",WebInspector.RemoteObject.fromPayload(exceptionObject)));}
836 if(callFrame.returnValue)
837 extraProperties.push(new WebInspector.RemoteObjectProperty("<return>",WebInspector.RemoteObject.fromPayload(callFrame.returnValue)));}
838 declarativeScope=true;break;case DebuggerAgent.ScopeType.Closure:title=WebInspector.UIString("Closure");emptyPlaceholder=WebInspector.UIString("No Variables");subtitle=undefined;declarativeScope=true;break;case DebuggerAgent.ScopeType.Catch:title=WebInspector.UIString("Catch");subtitle=undefined;declarativeScope=true;break;case DebuggerAgent.ScopeType.With:title=WebInspector.UIString("With Block");declarativeScope=false;break;case DebuggerAgent.ScopeType.Global:title=WebInspector.UIString("Global");declarativeScope=false;break;}
839 if(!title||title===subtitle)
840 subtitle=undefined;var scopeRef=declarativeScope?new WebInspector.ScopeRef(i,callFrame.id,undefined):undefined;var scopeObject=WebInspector.ScopeRemoteObject.fromPayload(scope.object,scopeRef);var section=new WebInspector.ObjectPropertiesSection(scopeObject,title,subtitle,emptyPlaceholder,true,extraProperties,WebInspector.ScopeVariableTreeElement);section.editInSelectedCallFrameWhenPaused=true;section.pane=this;if(scope.type===DebuggerAgent.ScopeType.Global)
841 section.expanded=false;else if(!foundLocalScope||scope.type===DebuggerAgent.ScopeType.Local||title in this._expandedSections)
842 section.expanded=true;this._sections.push(section);this.bodyElement.appendChild(section.element);}},__proto__:WebInspector.SidebarPane.prototype}
843 WebInspector.ScopeVariableTreeElement=function(property)
844 {WebInspector.ObjectPropertyTreeElement.call(this,property);}
845 WebInspector.ScopeVariableTreeElement.prototype={onattach:function()
846 {WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);if(this.hasChildren&&this.propertyIdentifier in this.treeOutline.section.pane._expandedProperties)
847 this.expand();},onexpand:function()
848 {this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier]=true;},oncollapse:function()
849 {delete this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier];},get propertyIdentifier()
850 {if("_propertyIdentifier"in this)
851 return this._propertyIdentifier;var section=this.treeOutline.section;this._propertyIdentifier=section.title+":"+(section.subtitle?section.subtitle+":":"")+this.propertyPath();return this._propertyIdentifier;},__proto__:WebInspector.ObjectPropertyTreeElement.prototype};WebInspector.SourcesNavigator=function()
852 {WebInspector.Object.call(this);this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.shrinkableTabs=true;this._tabbedPane.element.classList.add("navigator-tabbed-pane");this._sourcesView=new WebInspector.NavigatorView();this._sourcesView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected,this._sourceSelected,this);this._sourcesView.addEventListener(WebInspector.NavigatorView.Events.ItemSearchStarted,this._itemSearchStarted,this);this._sourcesView.addEventListener(WebInspector.NavigatorView.Events.ItemRenamingRequested,this._itemRenamingRequested,this);this._sourcesView.addEventListener(WebInspector.NavigatorView.Events.ItemCreationRequested,this._itemCreationRequested,this);this._contentScriptsView=new WebInspector.NavigatorView();this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected,this._sourceSelected,this);this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSearchStarted,this._itemSearchStarted,this);this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemRenamingRequested,this._itemRenamingRequested,this);this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemCreationRequested,this._itemCreationRequested,this);this._snippetsView=new WebInspector.SnippetsNavigatorView();this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected,this._sourceSelected,this);this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSearchStarted,this._itemSearchStarted,this);this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemRenamingRequested,this._itemRenamingRequested,this);this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemCreationRequested,this._itemCreationRequested,this);this._tabbedPane.appendTab(WebInspector.SourcesNavigator.SourcesTab,WebInspector.UIString("Sources"),this._sourcesView);this._tabbedPane.selectTab(WebInspector.SourcesNavigator.SourcesTab);this._tabbedPane.appendTab(WebInspector.SourcesNavigator.ContentScriptsTab,WebInspector.UIString("Content scripts"),this._contentScriptsView);this._tabbedPane.appendTab(WebInspector.SourcesNavigator.SnippetsTab,WebInspector.UIString("Snippets"),this._snippetsView);}
853 WebInspector.SourcesNavigator.Events={SourceSelected:"SourceSelected",ItemCreationRequested:"ItemCreationRequested",ItemRenamingRequested:"ItemRenamingRequested",ItemSearchStarted:"ItemSearchStarted",}
854 WebInspector.SourcesNavigator.SourcesTab="sources";WebInspector.SourcesNavigator.ContentScriptsTab="contentScripts";WebInspector.SourcesNavigator.SnippetsTab="snippets";WebInspector.SourcesNavigator.prototype={get view()
855 {return this._tabbedPane;},_navigatorViewForUISourceCode:function(uiSourceCode)
856 {if(uiSourceCode.isContentScript)
857 return this._contentScriptsView;else if(uiSourceCode.project().type()===WebInspector.projectTypes.Snippets)
858 return this._snippetsView;else
859 return this._sourcesView;},addUISourceCode:function(uiSourceCode)
860 {this._navigatorViewForUISourceCode(uiSourceCode).addUISourceCode(uiSourceCode);},removeUISourceCode:function(uiSourceCode)
861 {this._navigatorViewForUISourceCode(uiSourceCode).removeUISourceCode(uiSourceCode);},revealUISourceCode:function(uiSourceCode,select)
862 {this._navigatorViewForUISourceCode(uiSourceCode).revealUISourceCode(uiSourceCode,select);if(uiSourceCode.isContentScript)
863 this._tabbedPane.selectTab(WebInspector.SourcesNavigator.ContentScriptsTab);else if(uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets)
864 this._tabbedPane.selectTab(WebInspector.SourcesNavigator.SourcesTab);},updateIcon:function(uiSourceCode)
865 {this._navigatorViewForUISourceCode(uiSourceCode).updateIcon(uiSourceCode);},rename:function(uiSourceCode,callback)
866 {this._navigatorViewForUISourceCode(uiSourceCode).rename(uiSourceCode,callback);},_sourceSelected:function(event)
867 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.SourceSelected,event.data);},_itemSearchStarted:function(event)
868 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.ItemSearchStarted,event.data);},_itemRenamingRequested:function(event)
869 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.ItemRenamingRequested,event.data);},_itemCreationRequested:function(event)
870 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.ItemCreationRequested,event.data);},__proto__:WebInspector.Object.prototype}
871 WebInspector.SnippetsNavigatorView=function()
872 {WebInspector.NavigatorView.call(this);}
873 WebInspector.SnippetsNavigatorView.prototype={handleContextMenu:function(event)
874 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("New"),this._handleCreateSnippet.bind(this));contextMenu.show();},handleFileContextMenu:function(event,uiSourceCode)
875 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Run"),this._handleEvaluateSnippet.bind(this,uiSourceCode));contextMenu.appendItem(WebInspector.UIString("Rename"),this.requestRename.bind(this,uiSourceCode));contextMenu.appendItem(WebInspector.UIString("Remove"),this._handleRemoveSnippet.bind(this,uiSourceCode));contextMenu.appendSeparator();contextMenu.appendItem(WebInspector.UIString("New"),this._handleCreateSnippet.bind(this));contextMenu.show();},_handleEvaluateSnippet:function(uiSourceCode)
876 {if(uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets)
877 return;WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode);},_handleRemoveSnippet:function(uiSourceCode)
878 {if(uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets)
879 return;uiSourceCode.project().deleteFile(uiSourceCode.path());},_handleCreateSnippet:function()
880 {var data={};data.project=WebInspector.scriptSnippetModel.project();data.path="";this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemCreationRequested,data);},sourceDeleted:function(uiSourceCode)
881 {this._handleRemoveSnippet(uiSourceCode);},__proto__:WebInspector.NavigatorView.prototype};WebInspector.SourcesSearchScope=function()
882 {this._searchId=0;this._workspace=WebInspector.workspace;}
883 WebInspector.SourcesSearchScope.prototype={performIndexing:function(progress,indexingFinishedCallback)
884 {this.stopSearch();function filterOutServiceProjects(project)
885 {return!project.isServiceProject();}
886 var projects=this._workspace.projects().filter(filterOutServiceProjects);var barrier=new CallbackBarrier();var compositeProgress=new WebInspector.CompositeProgress(progress);progress.addEventListener(WebInspector.Progress.Events.Canceled,indexingCanceled.bind(this));for(var i=0;i<projects.length;++i){var project=projects[i];var projectProgress=compositeProgress.createSubProgress(project.uiSourceCodes().length);project.indexContent(projectProgress,barrier.createCallback());}
887 barrier.callWhenDone(indexingFinishedCallback.bind(this,true));function indexingCanceled()
888 {indexingFinishedCallback(false);progress.done();}},performSearch:function(searchConfig,progress,searchResultCallback,searchFinishedCallback)
889 {this.stopSearch();this._searchResultCallback=searchResultCallback;this._searchFinishedCallback=searchFinishedCallback;this._searchConfig=searchConfig;function filterOutServiceProjects(project)
890 {return!project.isServiceProject();}
891 var projects=this._workspace.projects().filter(filterOutServiceProjects);var barrier=new CallbackBarrier();var compositeProgress=new WebInspector.CompositeProgress(progress);for(var i=0;i<projects.length;++i){var project=projects[i];var weight=project.uiSourceCodes().length;var projectProgress=new WebInspector.CompositeProgress(compositeProgress.createSubProgress(weight));var findMatchingFilesProgress=projectProgress.createSubProgress();var searchContentProgress=projectProgress.createSubProgress();var barrierCallback=barrier.createCallback();var callback=this._processMatchingFilesForProject.bind(this,this._searchId,project,searchContentProgress,barrierCallback);project.findFilesMatchingSearchRequest(searchConfig.queries(),searchConfig.fileQueries(),!searchConfig.ignoreCase,searchConfig.isRegex,findMatchingFilesProgress,callback);}
892 barrier.callWhenDone(this._searchFinishedCallback.bind(this,true));},_processMatchingFilesForProject:function(searchId,project,progress,callback,files)
893 {if(searchId!==this._searchId){this._searchFinishedCallback(false);return;}
894 if(!files.length){progress.done();callback();return;}
895 progress.setTotalWork(files.length);var fileIndex=0;var maxFileContentRequests=20;var callbacksLeft=0;for(var i=0;i<maxFileContentRequests&&i<files.length;++i)
896 scheduleSearchInNextFileOrFinish.call(this);function searchInNextFile(path)
897 {var uiSourceCode=project.uiSourceCode(path);if(!uiSourceCode){--callbacksLeft;progress.worked(1);scheduleSearchInNextFileOrFinish.call(this);return;}
898 uiSourceCode.requestContent(contentLoaded.bind(this,path));}
899 function scheduleSearchInNextFileOrFinish()
900 {if(fileIndex>=files.length){if(!callbacksLeft){progress.done();callback();return;}
901 return;}
902 ++callbacksLeft;var path=files[fileIndex++];setTimeout(searchInNextFile.bind(this,path),0);}
903 function contentLoaded(path,content)
904 {function matchesComparator(a,b)
905 {return a.lineNumber-b.lineNumber;}
906 progress.worked(1);var matches=[];var queries=this._searchConfig.queries();if(content!==null){for(var i=0;i<queries.length;++i){var nextMatches=WebInspector.ContentProvider.performSearchInContent(content,queries[i],!this._searchConfig.ignoreCase,this._searchConfig.isRegex)
907 matches=matches.mergeOrdered(nextMatches,matchesComparator);}}
908 var uiSourceCode=project.uiSourceCode(path);if(matches&&uiSourceCode){var searchResult=new WebInspector.FileBasedSearchResultsPane.SearchResult(uiSourceCode,matches);this._searchResultCallback(searchResult);}
909 --callbacksLeft;scheduleSearchInNextFileOrFinish.call(this);}},stopSearch:function()
910 {++this._searchId;},createSearchResultsPane:function(searchConfig)
911 {return new WebInspector.FileBasedSearchResultsPane(searchConfig);}};WebInspector.StyleSheetOutlineDialog=function(view,uiSourceCode,selectItemCallback)
912 {WebInspector.SelectionDialogContentProvider.call(this);this._selectItemCallback=selectItemCallback;this._rules=[];this._view=view;this._uiSourceCode=uiSourceCode;this._requestItems();}
913 WebInspector.StyleSheetOutlineDialog.show=function(view,uiSourceCode,selectItemCallback)
914 {if(WebInspector.Dialog.currentInstance())
915 return null;var delegate=new WebInspector.StyleSheetOutlineDialog(view,uiSourceCode,selectItemCallback);var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(delegate);WebInspector.Dialog.show(view.element,filteredItemSelectionDialog);}
916 WebInspector.StyleSheetOutlineDialog.prototype={itemCount:function()
917 {return this._rules.length;},itemKeyAt:function(itemIndex)
918 {return this._rules[itemIndex].selectorText;},itemScoreAt:function(itemIndex,query)
919 {var rule=this._rules[itemIndex];return-rule.rawLocation.lineNumber;},renderItem:function(itemIndex,query,titleElement,subtitleElement)
920 {var rule=this._rules[itemIndex];titleElement.textContent=rule.selectorText;this.highlightRanges(titleElement,query);subtitleElement.textContent=":"+(rule.rawLocation.lineNumber+1);},_requestItems:function()
921 {function didGetAllStyleSheets(error,infos)
922 {if(error)
923 return;for(var i=0;i<infos.length;++i){var info=infos[i];if(info.sourceURL===this._uiSourceCode.url){WebInspector.CSSStyleSheet.createForId(info.styleSheetId,didGetStyleSheet.bind(this));return;}}}
924 CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));function didGetStyleSheet(styleSheet)
925 {if(!styleSheet)
926 return;this._rules=styleSheet.rules;this.refresh();}},selectItem:function(itemIndex,promptValue)
927 {var rule=this._rules[itemIndex];var lineNumber=rule.rawLocation.lineNumber;if(!isNaN(lineNumber)&&lineNumber>=0)
928 this._selectItemCallback(lineNumber,rule.rawLocation.columnNumber);},__proto__:WebInspector.SelectionDialogContentProvider.prototype};WebInspector.TabbedEditorContainerDelegate=function(){}
929 WebInspector.TabbedEditorContainerDelegate.prototype={viewForFile:function(uiSourceCode){}}
930 WebInspector.TabbedEditorContainer=function(delegate,settingName,placeholderText)
931 {WebInspector.Object.call(this);this._delegate=delegate;this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.setPlaceholderText(placeholderText);this._tabbedPane.setTabDelegate(new WebInspector.EditorContainerTabDelegate(this));this._tabbedPane.closeableTabs=true;this._tabbedPane.element.id="sources-editor-container-tabbed-pane";this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabClosed,this._tabClosed,this);this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected,this._tabSelected,this);this._tabIds=new Map();this._files={};this._previouslyViewedFilesSetting=WebInspector.settings.createSetting(settingName,[]);this._history=WebInspector.TabbedEditorContainer.History.fromObject(this._previouslyViewedFilesSetting.get());}
932 WebInspector.TabbedEditorContainer.Events={EditorSelected:"EditorSelected",EditorClosed:"EditorClosed"}
933 WebInspector.TabbedEditorContainer._tabId=0;WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount=30;WebInspector.TabbedEditorContainer.prototype={get view()
934 {return this._tabbedPane;},get visibleView()
935 {return this._tabbedPane.visibleView;},show:function(parentElement)
936 {this._tabbedPane.show(parentElement);},showFile:function(uiSourceCode)
937 {this._innerShowFile(uiSourceCode,true);},historyUISourceCodes:function()
938 {var uriToUISourceCode={};for(var id in this._files){var uiSourceCode=this._files[id];uriToUISourceCode[uiSourceCode.uri()]=uiSourceCode;}
939 var result=[];var uris=this._history._urls();for(var i=0;i<uris.length;++i){var uiSourceCode=uriToUISourceCode[uris[i]];if(uiSourceCode)
940 result.push(uiSourceCode);}
941 return result;},_addScrollAndSelectionListeners:function()
942 {if(!this._currentView)
943 return;this._currentView.addEventListener(WebInspector.SourceFrame.Events.ScrollChanged,this._scrollChanged,this);this._currentView.addEventListener(WebInspector.SourceFrame.Events.SelectionChanged,this._selectionChanged,this);},_removeScrollAndSelectionListeners:function()
944 {if(!this._currentView)
945 return;this._currentView.removeEventListener(WebInspector.SourceFrame.Events.ScrollChanged,this._scrollChanged,this);this._currentView.removeEventListener(WebInspector.SourceFrame.Events.SelectionChanged,this._selectionChanged,this);},_scrollChanged:function(event)
946 {var lineNumber=(event.data);this._history.updateScrollLineNumber(this._currentFile.uri(),lineNumber);this._history.save(this._previouslyViewedFilesSetting);},_selectionChanged:function(event)
947 {var range=(event.data);this._history.updateSelectionRange(this._currentFile.uri(),range);this._history.save(this._previouslyViewedFilesSetting);},_innerShowFile:function(uiSourceCode,userGesture)
948 {if(this._currentFile===uiSourceCode)
949 return;this._removeScrollAndSelectionListeners();this._currentFile=uiSourceCode;var tabId=this._tabIds.get(uiSourceCode)||this._appendFileTab(uiSourceCode,userGesture);this._tabbedPane.selectTab(tabId,userGesture);if(userGesture)
950 this._editorSelectedByUserAction();this._currentView=this.visibleView;this._addScrollAndSelectionListeners();var eventData={currentFile:this._currentFile,userGesture:userGesture};this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.EditorSelected,eventData);},_titleForFile:function(uiSourceCode)
951 {var maxDisplayNameLength=30;var title=uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLength);if(uiSourceCode.isDirty()||uiSourceCode.hasUnsavedCommittedChanges())
952 title+="*";return title;},_maybeCloseTab:function(id,nextTabId)
953 {var uiSourceCode=this._files[id];var shouldPrompt=uiSourceCode.isDirty()&&uiSourceCode.project().canSetFileContent();if(!shouldPrompt||confirm(WebInspector.UIString("Are you sure you want to close unsaved file: %s?",uiSourceCode.name()))){uiSourceCode.resetWorkingCopy();if(nextTabId)
954 this._tabbedPane.selectTab(nextTabId,true);this._tabbedPane.closeTab(id,true);return true;}
955 return false;},_closeTabs:function(ids)
956 {var dirtyTabs=[];var cleanTabs=[];for(var i=0;i<ids.length;++i){var id=ids[i];var uiSourceCode=this._files[id];if(uiSourceCode.isDirty())
957 dirtyTabs.push(id);else
958 cleanTabs.push(id);}
959 if(dirtyTabs.length)
960 this._tabbedPane.selectTab(dirtyTabs[0],true);this._tabbedPane.closeTabs(cleanTabs,true);for(var i=0;i<dirtyTabs.length;++i){var nextTabId=i+1<dirtyTabs.length?dirtyTabs[i+1]:null;if(!this._maybeCloseTab(dirtyTabs[i],nextTabId))
961 break;}},addUISourceCode:function(uiSourceCode)
962 {var uri=uiSourceCode.uri();if(this._userSelectedFiles)
963 return;var index=this._history.index(uri)
964 if(index===-1)
965 return;var tabId=this._tabIds.get(uiSourceCode)||this._appendFileTab(uiSourceCode,false);if(!this._currentFile)
966 return;if(!index){this._innerShowFile(uiSourceCode,false);return;}
967 var currentProjectType=this._currentFile.project().type();var addedProjectType=uiSourceCode.project().type();var snippetsProjectType=WebInspector.projectTypes.Snippets;if(this._history.index(this._currentFile.uri())&&currentProjectType===snippetsProjectType&&addedProjectType!==snippetsProjectType)
968 this._innerShowFile(uiSourceCode,false);},removeUISourceCode:function(uiSourceCode)
969 {this.removeUISourceCodes([uiSourceCode]);},removeUISourceCodes:function(uiSourceCodes)
970 {var tabIds=[];for(var i=0;i<uiSourceCodes.length;++i){var uiSourceCode=uiSourceCodes[i];var tabId=this._tabIds.get(uiSourceCode);if(tabId)
971 tabIds.push(tabId);}
972 this._tabbedPane.closeTabs(tabIds);},_editorClosedByUserAction:function(uiSourceCode)
973 {this._userSelectedFiles=true;this._history.remove(uiSourceCode.uri());this._updateHistory();},_editorSelectedByUserAction:function()
974 {this._userSelectedFiles=true;this._updateHistory();},_updateHistory:function()
975 {var tabIds=this._tabbedPane.lastOpenedTabIds(WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount);function tabIdToURI(tabId)
976 {return this._files[tabId].uri();}
977 this._history.update(tabIds.map(tabIdToURI.bind(this)));this._history.save(this._previouslyViewedFilesSetting);},_tooltipForFile:function(uiSourceCode)
978 {return uiSourceCode.originURL();},_appendFileTab:function(uiSourceCode,userGesture)
979 {var view=this._delegate.viewForFile(uiSourceCode);var title=this._titleForFile(uiSourceCode);var tooltip=this._tooltipForFile(uiSourceCode);var tabId=this._generateTabId();this._tabIds.put(uiSourceCode,tabId);this._files[tabId]=uiSourceCode;var savedSelectionRange=this._history.selectionRange(uiSourceCode.uri());if(savedSelectionRange)
980 view.setSelection(savedSelectionRange);var savedScrollLineNumber=this._history.scrollLineNumber(uiSourceCode.uri());if(savedScrollLineNumber)
981 view.scrollToLine(savedScrollLineNumber);this._tabbedPane.appendTab(tabId,title,view,tooltip,userGesture);this._updateFileTitle(uiSourceCode);this._addUISourceCodeListeners(uiSourceCode);return tabId;},_tabClosed:function(event)
982 {var tabId=(event.data.tabId);var userGesture=(event.data.isUserGesture);var uiSourceCode=this._files[tabId];if(this._currentFile===uiSourceCode){this._removeScrollAndSelectionListeners();delete this._currentView;delete this._currentFile;}
983 this._tabIds.remove(uiSourceCode);delete this._files[tabId];this._removeUISourceCodeListeners(uiSourceCode);this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.EditorClosed,uiSourceCode);if(userGesture)
984 this._editorClosedByUserAction(uiSourceCode);},_tabSelected:function(event)
985 {var tabId=(event.data.tabId);var userGesture=(event.data.isUserGesture);var uiSourceCode=this._files[tabId];this._innerShowFile(uiSourceCode,userGesture);},_addUISourceCodeListeners:function(uiSourceCode)
986 {uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged,this._uiSourceCodeTitleChanged,this);uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._uiSourceCodeWorkingCopyChanged,this);uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._uiSourceCodeWorkingCopyCommitted,this);uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SavedStateUpdated,this._uiSourceCodeSavedStateUpdated,this);uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged,this._uiSourceCodeFormattedChanged,this);},_removeUISourceCodeListeners:function(uiSourceCode)
987 {uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged,this._uiSourceCodeTitleChanged,this);uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._uiSourceCodeWorkingCopyChanged,this);uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._uiSourceCodeWorkingCopyCommitted,this);uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.SavedStateUpdated,this._uiSourceCodeSavedStateUpdated,this);uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged,this._uiSourceCodeFormattedChanged,this);},_updateFileTitle:function(uiSourceCode)
988 {var tabId=this._tabIds.get(uiSourceCode);if(tabId){var title=this._titleForFile(uiSourceCode);this._tabbedPane.changeTabTitle(tabId,title);if(uiSourceCode.hasUnsavedCommittedChanges())
989 this._tabbedPane.setTabIcon(tabId,"editor-container-unsaved-committed-changes-icon",WebInspector.UIString("Changes to this file were not saved to file system."));else
990 this._tabbedPane.setTabIcon(tabId,"");}},_uiSourceCodeTitleChanged:function(event)
991 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);this._updateHistory();},_uiSourceCodeWorkingCopyChanged:function(event)
992 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},_uiSourceCodeWorkingCopyCommitted:function(event)
993 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},_uiSourceCodeSavedStateUpdated:function(event)
994 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},_uiSourceCodeFormattedChanged:function(event)
995 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},reset:function()
996 {delete this._userSelectedFiles;},_generateTabId:function()
997 {return"tab_"+(WebInspector.TabbedEditorContainer._tabId++);},currentFile:function()
998 {return this._currentFile;},__proto__:WebInspector.Object.prototype}
999 WebInspector.TabbedEditorContainer.HistoryItem=function(url,selectionRange,scrollLineNumber)
1000 {this.url=url;this._isSerializable=url.length<WebInspector.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit;this.selectionRange=selectionRange;this.scrollLineNumber=scrollLineNumber;}
1001 WebInspector.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit=4096;WebInspector.TabbedEditorContainer.HistoryItem.fromObject=function(serializedHistoryItem)
1002 {var selectionRange=serializedHistoryItem.selectionRange?WebInspector.TextRange.fromObject(serializedHistoryItem.selectionRange):undefined;return new WebInspector.TabbedEditorContainer.HistoryItem(serializedHistoryItem.url,selectionRange,serializedHistoryItem.scrollLineNumber);}
1003 WebInspector.TabbedEditorContainer.HistoryItem.prototype={serializeToObject:function()
1004 {if(!this._isSerializable)
1005 return null;var serializedHistoryItem={};serializedHistoryItem.url=this.url;serializedHistoryItem.selectionRange=this.selectionRange;serializedHistoryItem.scrollLineNumber=this.scrollLineNumber;return serializedHistoryItem;}}
1006 WebInspector.TabbedEditorContainer.History=function(items)
1007 {this._items=items;this._rebuildItemIndex();}
1008 WebInspector.TabbedEditorContainer.History.fromObject=function(serializedHistory)
1009 {var items=[];for(var i=0;i<serializedHistory.length;++i)
1010 items.push(WebInspector.TabbedEditorContainer.HistoryItem.fromObject(serializedHistory[i]));return new WebInspector.TabbedEditorContainer.History(items);}
1011 WebInspector.TabbedEditorContainer.History.prototype={index:function(url)
1012 {var index=this._itemsIndex[url];if(typeof index==="number")
1013 return index;return-1;},_rebuildItemIndex:function()
1014 {this._itemsIndex={};for(var i=0;i<this._items.length;++i){console.assert(!this._itemsIndex.hasOwnProperty(this._items[i].url));this._itemsIndex[this._items[i].url]=i;}},selectionRange:function(url)
1015 {var index=this.index(url);return index!==-1?this._items[index].selectionRange:undefined;},updateSelectionRange:function(url,selectionRange)
1016 {if(!selectionRange)
1017 return;var index=this.index(url);if(index===-1)
1018 return;this._items[index].selectionRange=selectionRange;},scrollLineNumber:function(url)
1019 {var index=this.index(url);return index!==-1?this._items[index].scrollLineNumber:undefined;},updateScrollLineNumber:function(url,scrollLineNumber)
1020 {var index=this.index(url);if(index===-1)
1021 return;this._items[index].scrollLineNumber=scrollLineNumber;},update:function(urls)
1022 {for(var i=urls.length-1;i>=0;--i){var index=this.index(urls[i]);var item;if(index!==-1){item=this._items[index];this._items.splice(index,1);}else
1023 item=new WebInspector.TabbedEditorContainer.HistoryItem(urls[i]);this._items.unshift(item);this._rebuildItemIndex();}},remove:function(url)
1024 {var index=this.index(url);if(index!==-1){this._items.splice(index,1);this._rebuildItemIndex();}},save:function(setting)
1025 {setting.set(this._serializeToObject());},_serializeToObject:function()
1026 {var serializedHistory=[];for(var i=0;i<this._items.length;++i){var serializedItem=this._items[i].serializeToObject();if(serializedItem)
1027 serializedHistory.push(serializedItem);if(serializedHistory.length===WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount)
1028 break;}
1029 return serializedHistory;},_urls:function()
1030 {var result=[];for(var i=0;i<this._items.length;++i)
1031 result.push(this._items[i].url);return result;}}
1032 WebInspector.EditorContainerTabDelegate=function(editorContainer)
1033 {this._editorContainer=editorContainer;}
1034 WebInspector.EditorContainerTabDelegate.prototype={closeTabs:function(tabbedPane,ids)
1035 {this._editorContainer._closeTabs(ids);}};WebInspector.WatchExpressionsSidebarPane=function()
1036 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Watch Expressions"));this.section=new WebInspector.WatchExpressionsSection();this.bodyElement.appendChild(this.section.element);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);var addButton=document.createElement("button");addButton.className="pane-title-button add";addButton.addEventListener("click",this._addButtonClicked.bind(this),false);this.titleElement.appendChild(addButton);addButton.title=WebInspector.UIString("Add watch expression");this._requiresUpdate=true;}
1037 WebInspector.WatchExpressionsSidebarPane.prototype={wasShown:function()
1038 {this._refreshExpressionsIfNeeded();},reset:function()
1039 {this.refreshExpressions();},refreshExpressions:function()
1040 {this._requiresUpdate=true;this._refreshExpressionsIfNeeded();},addExpression:function(expression)
1041 {this.section.addExpression(expression);this.expand();},_refreshExpressionsIfNeeded:function()
1042 {if(this._requiresUpdate&&this.isShowing()){this.section.update();delete this._requiresUpdate;}else
1043 this._requiresUpdate=true;},_addButtonClicked:function(event)
1044 {event.consume();this.expand();this.section.addNewExpressionAndEdit();},_refreshButtonClicked:function(event)
1045 {event.consume();this.refreshExpressions();},__proto__:WebInspector.SidebarPane.prototype}
1046 WebInspector.WatchExpressionsSection=function()
1047 {this._watchObjectGroupId="watch-group";WebInspector.ObjectPropertiesSection.call(this,WebInspector.RemoteObject.fromPrimitiveValue(""));this.treeElementConstructor=WebInspector.WatchedPropertyTreeElement;this._expandedExpressions={};this._expandedProperties={};this.emptyElement=document.createElement("div");this.emptyElement.className="info";this.emptyElement.textContent=WebInspector.UIString("No Watch Expressions");this.watchExpressions=WebInspector.settings.watchExpressions.get();this.headerElement.className="hidden";this.editable=true;this.expanded=true;this.propertiesElement.classList.add("watch-expressions");this.element.addEventListener("mousemove",this._mouseMove.bind(this),true);this.element.addEventListener("mouseout",this._mouseOut.bind(this),true);this.element.addEventListener("dblclick",this._sectionDoubleClick.bind(this),false);this.emptyElement.addEventListener("contextmenu",this._emptyElementContextMenu.bind(this),false);}
1048 WebInspector.WatchExpressionsSection.NewWatchExpression="\xA0";WebInspector.WatchExpressionsSection.prototype={update:function(e)
1049 {if(e)
1050 e.consume();function appendResult(expression,watchIndex,result,wasThrown)
1051 {if(!result)
1052 return;var property=new WebInspector.RemoteObjectProperty(expression,result);property.watchIndex=watchIndex;property.wasThrown=wasThrown;properties.push(property);if(properties.length==propertyCount){this.updateProperties(properties,[],WebInspector.WatchExpressionTreeElement,WebInspector.WatchExpressionsSection.CompareProperties);if(this._newExpressionAdded){delete this._newExpressionAdded;var treeElement=this.findAddedTreeElement();if(treeElement)
1053 treeElement.startEditing();}
1054 if(this._lastMouseMovePageY)
1055 this._updateHoveredElement(this._lastMouseMovePageY);}}
1056 RuntimeAgent.releaseObjectGroup(this._watchObjectGroupId)
1057 var properties=[];var propertyCount=0;for(var i=0;i<this.watchExpressions.length;++i){if(!this.watchExpressions[i])
1058 continue;++propertyCount;}
1059 for(var i=0;i<this.watchExpressions.length;++i){var expression=this.watchExpressions[i];if(!expression)
1060 continue;WebInspector.runtimeModel.evaluate(expression,this._watchObjectGroupId,false,true,false,false,appendResult.bind(this,expression,i));}
1061 if(!propertyCount){if(!this.emptyElement.parentNode)
1062 this.element.appendChild(this.emptyElement);}else{if(this.emptyElement.parentNode)
1063 this.element.removeChild(this.emptyElement);}
1064 this.expanded=(propertyCount!=0);},addExpression:function(expression)
1065 {this.watchExpressions.push(expression);this.saveExpressions();this.update();},addNewExpressionAndEdit:function()
1066 {this._newExpressionAdded=true;this.watchExpressions.push(WebInspector.WatchExpressionsSection.NewWatchExpression);this.update();},_sectionDoubleClick:function(event)
1067 {if(event.target!==this.element&&event.target!==this.propertiesElement&&event.target!==this.emptyElement)
1068 return;event.consume();this.addNewExpressionAndEdit();},updateExpression:function(element,value)
1069 {if(value===null){var index=element.property.watchIndex;this.watchExpressions.splice(index,1);}
1070 else
1071 this.watchExpressions[element.property.watchIndex]=value;this.saveExpressions();this.update();},_deleteAllExpressions:function()
1072 {this.watchExpressions=[];this.saveExpressions();this.update();},findAddedTreeElement:function()
1073 {var children=this.propertiesTreeOutline.children;for(var i=0;i<children.length;++i){if(children[i].property.name===WebInspector.WatchExpressionsSection.NewWatchExpression)
1074 return children[i];}
1075 return null;},saveExpressions:function()
1076 {var toSave=[];for(var i=0;i<this.watchExpressions.length;i++)
1077 if(this.watchExpressions[i])
1078 toSave.push(this.watchExpressions[i]);WebInspector.settings.watchExpressions.set(toSave);return toSave.length;},_mouseMove:function(e)
1079 {if(this.propertiesElement.firstChild)
1080 this._updateHoveredElement(e.pageY);},_mouseOut:function()
1081 {if(this._hoveredElement){this._hoveredElement.classList.remove("hovered");delete this._hoveredElement;}
1082 delete this._lastMouseMovePageY;},_updateHoveredElement:function(pageY)
1083 {var candidateElement=this.propertiesElement.firstChild;while(true){var next=candidateElement.nextSibling;while(next&&!next.clientHeight)
1084 next=next.nextSibling;if(!next||next.totalOffsetTop()>pageY)
1085 break;candidateElement=next;}
1086 if(this._hoveredElement!==candidateElement){if(this._hoveredElement)
1087 this._hoveredElement.classList.remove("hovered");if(candidateElement)
1088 candidateElement.classList.add("hovered");this._hoveredElement=candidateElement;}
1089 this._lastMouseMovePageY=pageY;},_emptyElementContextMenu:function(event)
1090 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add watch expression":"Add Watch Expression"),this.addNewExpressionAndEdit.bind(this));contextMenu.show();},__proto__:WebInspector.ObjectPropertiesSection.prototype}
1091 WebInspector.WatchExpressionsSection.CompareProperties=function(propertyA,propertyB)
1092 {if(propertyA.watchIndex==propertyB.watchIndex)
1093 return 0;else if(propertyA.watchIndex<propertyB.watchIndex)
1094 return-1;else
1095 return 1;}
1096 WebInspector.WatchExpressionTreeElement=function(property)
1097 {WebInspector.ObjectPropertyTreeElement.call(this,property);}
1098 WebInspector.WatchExpressionTreeElement.prototype={onexpand:function()
1099 {WebInspector.ObjectPropertyTreeElement.prototype.onexpand.call(this);this.treeOutline.section._expandedExpressions[this._expression()]=true;},oncollapse:function()
1100 {WebInspector.ObjectPropertyTreeElement.prototype.oncollapse.call(this);delete this.treeOutline.section._expandedExpressions[this._expression()];},onattach:function()
1101 {WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);if(this.treeOutline.section._expandedExpressions[this._expression()])
1102 this.expanded=true;},_expression:function()
1103 {return this.property.name;},update:function()
1104 {WebInspector.ObjectPropertyTreeElement.prototype.update.call(this);if(this.property.wasThrown){this.valueElement.textContent=WebInspector.UIString("<not available>");this.listItemElement.classList.add("dimmed");}else
1105 this.listItemElement.classList.remove("dimmed");var deleteButton=document.createElement("input");deleteButton.type="button";deleteButton.title=WebInspector.UIString("Delete watch expression.");deleteButton.classList.add("enabled-button");deleteButton.classList.add("delete-button");deleteButton.addEventListener("click",this._deleteButtonClicked.bind(this),false);this.listItemElement.addEventListener("contextmenu",this._contextMenu.bind(this),false);this.listItemElement.insertBefore(deleteButton,this.listItemElement.firstChild);},populateContextMenu:function(contextMenu)
1106 {if(!this.isEditing()){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add watch expression":"Add Watch Expression"),this.treeOutline.section.addNewExpressionAndEdit.bind(this.treeOutline.section));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Delete watch expression":"Delete Watch Expression"),this._deleteButtonClicked.bind(this));}
1107 if(this.treeOutline.section.watchExpressions.length>1)
1108 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Delete all watch expressions":"Delete All Watch Expressions"),this._deleteAllButtonClicked.bind(this));},_contextMenu:function(event)
1109 {var contextMenu=new WebInspector.ContextMenu(event);this.populateContextMenu(contextMenu);contextMenu.show();},_deleteAllButtonClicked:function()
1110 {this.treeOutline.section._deleteAllExpressions();},_deleteButtonClicked:function()
1111 {this.treeOutline.section.updateExpression(this,null);},renderPromptAsBlock:function()
1112 {return true;},elementAndValueToEdit:function(event)
1113 {return[this.nameElement,this.property.name.trim()];},editingCancelled:function(element,context)
1114 {if(!context.elementToEdit.textContent)
1115 this.treeOutline.section.updateExpression(this,null);WebInspector.ObjectPropertyTreeElement.prototype.editingCancelled.call(this,element,context);},applyExpression:function(expression,updateInterface)
1116 {expression=expression.trim();if(!expression)
1117 expression=null;this.property.name=expression;this.treeOutline.section.updateExpression(this,expression);},__proto__:WebInspector.ObjectPropertyTreeElement.prototype}
1118 WebInspector.WatchedPropertyTreeElement=function(property)
1119 {WebInspector.ObjectPropertyTreeElement.call(this,property);}
1120 WebInspector.WatchedPropertyTreeElement.prototype={onattach:function()
1121 {WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);if(this.hasChildren&&this.propertyPath()in this.treeOutline.section._expandedProperties)
1122 this.expand();},onexpand:function()
1123 {WebInspector.ObjectPropertyTreeElement.prototype.onexpand.call(this);this.treeOutline.section._expandedProperties[this.propertyPath()]=true;},oncollapse:function()
1124 {WebInspector.ObjectPropertyTreeElement.prototype.oncollapse.call(this);delete this.treeOutline.section._expandedProperties[this.propertyPath()];},__proto__:WebInspector.ObjectPropertyTreeElement.prototype};WebInspector.Worker=function(id,url,shared)
1125 {this.id=id;this.url=url;this.shared=shared;}
1126 WebInspector.WorkersSidebarPane=function(workerManager)
1127 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Workers"));this._enableWorkersCheckbox=new WebInspector.Checkbox(WebInspector.UIString("Pause on start"),"sidebar-label",WebInspector.UIString("Automatically attach to new workers and pause them. Enabling this option will force opening inspector for all new workers."));this._enableWorkersCheckbox.element.id="pause-workers-checkbox";this.bodyElement.appendChild(this._enableWorkersCheckbox.element);this._enableWorkersCheckbox.addEventListener(this._autoattachToWorkersClicked.bind(this));this._enableWorkersCheckbox.checked=false;var note=this.bodyElement.createChild("div");note.id="shared-workers-list";note.classList.add("sidebar-label")
1128 note.textContent=WebInspector.UIString("Shared workers can be inspected in the Task Manager");var separator=this.bodyElement.createChild("div","sidebar-separator");separator.textContent=WebInspector.UIString("Dedicated worker inspectors");this._workerListElement=document.createElement("ol");this._workerListElement.tabIndex=0;this._workerListElement.classList.add("properties-tree");this._workerListElement.classList.add("sidebar-label");this.bodyElement.appendChild(this._workerListElement);this._idToWorkerItem={};this._workerManager=workerManager;workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerAdded,this._workerAdded,this);workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerRemoved,this._workerRemoved,this);workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkersCleared,this._workersCleared,this);}
1129 WebInspector.WorkersSidebarPane.prototype={_workerAdded:function(event)
1130 {this._addWorker(event.data.workerId,event.data.url,event.data.inspectorConnected);},_workerRemoved:function(event)
1131 {this._idToWorkerItem[event.data].remove();delete this._idToWorkerItem[event.data];},_workersCleared:function(event)
1132 {this._idToWorkerItem={};this._workerListElement.removeChildren();},_addWorker:function(workerId,url,inspectorConnected)
1133 {var item=this._workerListElement.createChild("div","dedicated-worker-item");var link=item.createChild("a");link.textContent=url;link.href="#";link.target="_blank";link.addEventListener("click",this._workerItemClicked.bind(this,workerId),true);this._idToWorkerItem[workerId]=item;},_workerItemClicked:function(workerId,event)
1134 {event.preventDefault();this._workerManager.openWorkerInspector(workerId);},_autoattachToWorkersClicked:function(event)
1135 {WorkerAgent.setAutoconnectToWorkers(this._enableWorkersCheckbox.checked);},__proto__:WebInspector.SidebarPane.prototype};WebInspector.SourcesPanel=function(workspaceForTest)
1136 {WebInspector.Panel.call(this,"sources");this.registerRequiredCSS("sourcesPanel.css");this.registerRequiredCSS("textPrompt.css");WebInspector.settings.navigatorWasOnceHidden=WebInspector.settings.createSetting("navigatorWasOnceHidden",false);WebInspector.settings.debuggerSidebarHidden=WebInspector.settings.createSetting("debuggerSidebarHidden",false);WebInspector.settings.showEditorInDrawer=WebInspector.settings.createSetting("showEditorInDrawer",true);this._workspace=workspaceForTest||WebInspector.workspace;function viewGetter()
1137 {return this;}
1138 WebInspector.GoToLineDialog.install(this,viewGetter.bind(this));var helpSection=WebInspector.shortcutsScreen.section(WebInspector.UIString("Sources Panel"));this.debugToolbar=this._createDebugToolbar();const initialDebugSidebarWidth=225;const minimumDebugSidebarWidthPercent=0.5;this.createSidebarView(this.element,WebInspector.SidebarView.SidebarPosition.End,initialDebugSidebarWidth);this.splitView.element.id="scripts-split-view";this.splitView.setSidebarElementConstraints(Preferences.minScriptsSidebarWidth);this.splitView.setMainElementConstraints(minimumDebugSidebarWidthPercent);const initialNavigatorWidth=225;const minimumViewsContainerWidthPercent=0.5;this.editorView=new WebInspector.SidebarView(WebInspector.SidebarView.SidebarPosition.Start,"scriptsPanelNavigatorSidebarWidth",initialNavigatorWidth);this.editorView.element.id="scripts-editor-split-view";this.editorView.element.tabIndex=0;this.editorView.setSidebarElementConstraints(Preferences.minScriptsSidebarWidth);this.editorView.setMainElementConstraints(minimumViewsContainerWidthPercent);this.splitView.setMainView(this.editorView);this._navigator=new WebInspector.SourcesNavigator();this.editorView.setSidebarView(this._navigator.view);var tabbedEditorPlaceholderText=WebInspector.isMac()?WebInspector.UIString("Hit Cmd+O to open a file"):WebInspector.UIString("Hit Ctrl+O to open a file");this.editorView.mainElement().classList.add("vbox");this.editorView.sidebarElement().classList.add("vbox");this.sourcesView=new WebInspector.SourcesView();this._searchableView=new WebInspector.SearchableView(this);this._searchableView.setMinimalSearchQuerySize(0);this._searchableView.show(this.sourcesView.element);this._editorContainer=new WebInspector.TabbedEditorContainer(this,"previouslyViewedFiles",tabbedEditorPlaceholderText);this._editorContainer.show(this._searchableView.element);this._navigatorController=new WebInspector.NavigatorOverlayController(this.editorView,this._navigator.view,this._editorContainer.view);this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceSelected,this._sourceSelected,this);this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.ItemSearchStarted,this._itemSearchStarted,this);this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.ItemCreationRequested,this._itemCreationRequested,this);this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.ItemRenamingRequested,this._itemRenamingRequested,this);this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorSelected,this._editorSelected,this);this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorClosed,this._editorClosed,this);this._debugSidebarResizeWidgetElement=document.createElementWithClass("div","resizer-widget");this._debugSidebarResizeWidgetElement.id="scripts-debug-sidebar-resizer-widget";this.splitView.installResizer(this._debugSidebarResizeWidgetElement);this.sidebarPanes={};this.sidebarPanes.watchExpressions=new WebInspector.WatchExpressionsSidebarPane();this.sidebarPanes.callstack=new WebInspector.CallStackSidebarPane();this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.CallFrameSelected,this._callFrameSelectedInSidebar.bind(this));this.sidebarPanes.callstack.addEventListener(WebInspector.CallStackSidebarPane.Events.CallFrameRestarted,this._callFrameRestartedInSidebar.bind(this));this.sidebarPanes.scopechain=new WebInspector.ScopeChainSidebarPane();this.sidebarPanes.jsBreakpoints=new WebInspector.JavaScriptBreakpointsSidebarPane(WebInspector.breakpointManager,this._showSourceLocation.bind(this));this.sidebarPanes.domBreakpoints=WebInspector.domBreakpointsSidebarPane.createProxy(this);this.sidebarPanes.xhrBreakpoints=new WebInspector.XHRBreakpointsSidebarPane();this.sidebarPanes.eventListenerBreakpoints=new WebInspector.EventListenerBreakpointsSidebarPane();if(Capabilities.canInspectWorkers&&!WebInspector.WorkerManager.isWorkerFrontend()){WorkerAgent.enable();this.sidebarPanes.workerList=new WebInspector.WorkersSidebarPane(WebInspector.workerManager);}
1139 function currentSourceFrame()
1140 {var uiSourceCode=this.currentUISourceCode();if(!uiSourceCode)
1141 return null;return this._sourceFramesByUISourceCode.get(uiSourceCode);}
1142 this._historyManager=new WebInspector.EditingLocationHistoryManager(this,currentSourceFrame.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToPreviousLocation,this._onJumpToPreviousLocation.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToNextLocation,this._onJumpToNextLocation.bind(this));this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToMember,this._showOutlineDialog.bind(this));this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint,this._toggleBreakpoint.bind(this));this._extensionSidebarPanes=[];this._toggleFormatSourceButton=new WebInspector.StatusBarButton(WebInspector.UIString("Pretty print"),"sources-toggle-pretty-print-status-bar-item");this._toggleFormatSourceButton.toggled=false;this._toggleFormatSourceButton.addEventListener("click",this._toggleFormatSource,this);this._scriptViewStatusBarItemsContainer=document.createElement("div");this._scriptViewStatusBarItemsContainer.className="inline-block";this._scriptViewStatusBarTextContainer=document.createElement("div");this._scriptViewStatusBarTextContainer.className="inline-block";this._statusBarContainerElement=this.sourcesView.element.createChild("div","sources-status-bar");this._statusBarContainerElement.appendChild(this._toggleFormatSourceButton.element);this._statusBarContainerElement.appendChild(this._scriptViewStatusBarItemsContainer);this._statusBarContainerElement.appendChild(this._scriptViewStatusBarTextContainer);this._installDebuggerSidebarController();WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged,this._dockSideChanged.bind(this));WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this));this._dockSideChanged();this._sourceFramesByUISourceCode=new Map();this._updateDebuggerButtons();this._pauseOnExceptionStateChanged();if(WebInspector.debuggerModel.isPaused())
1143 this._showDebuggerPausedDetails();WebInspector.settings.pauseOnExceptionStateString.addChangeListener(this._pauseOnExceptionStateChanged,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled,this._debuggerWasEnabled,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled,this._debuggerWasDisabled,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused,this._debuggerPaused,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerResumed,this._debuggerResumed,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.CallFrameSelected,this._callFrameSelected,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame,this._consoleCommandEvaluatedInSelectedCallFrame,this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointsActiveStateChanged,this._breakpointsActiveStateChanged,this);WebInspector.startBatchUpdate();this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));WebInspector.endBatchUpdate();this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved,this._uiSourceCodeRemoved,this);this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset,this._projectWillReset.bind(this),this);WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared,this._debuggerReset,this);this._boundOnKeyUp=this._onKeyUp.bind(this);this._boundOnKeyDown=this._onKeyDown.bind(this);function handleBeforeUnload(event)
1144 {if(event.returnValue)
1145 return;var unsavedSourceCodes=WebInspector.workspace.unsavedSourceCodes();if(!unsavedSourceCodes.length)
1146 return;event.returnValue=WebInspector.UIString("DevTools have unsaved changes that will be permanently lost.");WebInspector.showPanel("sources");for(var i=0;i<unsavedSourceCodes.length;++i)
1147 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]);}
1148 window.addEventListener("beforeunload",handleBeforeUnload.bind(this),true);}
1149 WebInspector.SourcesPanel.PauseOnExceptionsStates=[WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions,WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions,WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions];WebInspector.SourcesPanel.prototype={_onJumpToPreviousLocation:function(event)
1150 {this._historyManager.rollback();return true;},_onJumpToNextLocation:function(event)
1151 {this._historyManager.rollover();return true;},defaultFocusedElement:function()
1152 {return this._editorContainer.view.defaultFocusedElement()||this._navigator.view.defaultFocusedElement();},get paused()
1153 {return this._paused;},wasShown:function()
1154 {WebInspector.inspectorView.closeViewInDrawer("editor");this.editorView.setMainView(this.sourcesView);WebInspector.Panel.prototype.wasShown.call(this);this._navigatorController.wasShown();this.element.addEventListener("keydown",this._boundOnKeyDown,false);this.element.addEventListener("keyup",this._boundOnKeyUp,false);},willHide:function()
1155 {this.element.removeEventListener("keydown",this._boundOnKeyDown,false);this.element.removeEventListener("keyup",this._boundOnKeyUp,false);WebInspector.Panel.prototype.willHide.call(this);},searchableView:function()
1156 {return this._searchableView;},_uiSourceCodeAdded:function(event)
1157 {var uiSourceCode=(event.data);this._addUISourceCode(uiSourceCode);},_addUISourceCode:function(uiSourceCode)
1158 {if(this._toggleFormatSourceButton.toggled)
1159 uiSourceCode.setFormatted(true);if(uiSourceCode.project().isServiceProject())
1160 return;this._navigator.addUISourceCode(uiSourceCode);this._editorContainer.addUISourceCode(uiSourceCode);var currentUISourceCode=this._currentUISourceCode;if(currentUISourceCode&&currentUISourceCode.project().isServiceProject()&&currentUISourceCode!==uiSourceCode&&currentUISourceCode.url===uiSourceCode.url){this._showFile(uiSourceCode);this._editorContainer.removeUISourceCode(currentUISourceCode);}},_uiSourceCodeRemoved:function(event)
1161 {var uiSourceCode=(event.data);this._removeUISourceCodes([uiSourceCode]);},_removeUISourceCodes:function(uiSourceCodes)
1162 {for(var i=0;i<uiSourceCodes.length;++i){this._navigator.removeUISourceCode(uiSourceCodes[i]);this._removeSourceFrame(uiSourceCodes[i]);this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]);}
1163 this._editorContainer.removeUISourceCodes(uiSourceCodes);},_consoleCommandEvaluatedInSelectedCallFrame:function(event)
1164 {this.sidebarPanes.scopechain.update(WebInspector.debuggerModel.selectedCallFrame());},_debuggerPaused:function()
1165 {WebInspector.inspectorView.setCurrentPanel(this);this._showDebuggerPausedDetails();},_showDebuggerPausedDetails:function()
1166 {var details=WebInspector.debuggerModel.debuggerPausedDetails();this._paused=true;this._waitingToPause=false;this._stepping=false;this._updateDebuggerButtons();this.sidebarPanes.callstack.update(details.callFrames,details.asyncStackTrace);function didCreateBreakpointHitStatusMessage(element)
1167 {this.sidebarPanes.callstack.setStatus(element);}
1168 function didGetUILocation(uiLocation)
1169 {var breakpoint=WebInspector.breakpointManager.findBreakpoint(uiLocation.uiSourceCode,uiLocation.lineNumber);if(!breakpoint)
1170 return;this.sidebarPanes.jsBreakpoints.highlightBreakpoint(breakpoint);this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a JavaScript breakpoint."));}
1171 if(details.reason===WebInspector.DebuggerModel.BreakReason.DOM){WebInspector.domBreakpointsSidebarPane.highlightBreakpoint(details.auxData);WebInspector.domBreakpointsSidebarPane.createBreakpointHitStatusMessage(details.auxData,didCreateBreakpointHitStatusMessage.bind(this));}else if(details.reason===WebInspector.DebuggerModel.BreakReason.EventListener){var eventName=details.auxData.eventName;this.sidebarPanes.eventListenerBreakpoints.highlightBreakpoint(details.auxData.eventName);var eventNameForUI=WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName,details.auxData);this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a \"%s\" Event Listener.",eventNameForUI));}else if(details.reason===WebInspector.DebuggerModel.BreakReason.XHR){this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]);this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest."));}else if(details.reason===WebInspector.DebuggerModel.BreakReason.Exception)
1172 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.",details.auxData.description));else if(details.reason===WebInspector.DebuggerModel.BreakReason.Assert)
1173 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));else if(details.reason===WebInspector.DebuggerModel.BreakReason.CSPViolation)
1174 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".",details.auxData["directiveText"]));else if(details.reason===WebInspector.DebuggerModel.BreakReason.DebugCommand)
1175 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a debugged function"));else{if(details.callFrames.length)
1176 details.callFrames[0].createLiveLocation(didGetUILocation.bind(this));else
1177 console.warn("ScriptsPanel paused, but callFrames.length is zero.");}
1178 this._enableDebuggerSidebar(true);this._toggleDebuggerSidebarButton.setEnabled(false);window.focus();InspectorFrontendHost.bringToFront();},_debuggerResumed:function()
1179 {this._paused=false;this._waitingToPause=false;this._stepping=false;this._clearInterface();this._toggleDebuggerSidebarButton.setEnabled(true);},_debuggerWasEnabled:function()
1180 {this._updateDebuggerButtons();},_debuggerWasDisabled:function()
1181 {this._debuggerReset();},_debuggerReset:function()
1182 {this._debuggerResumed();this.sidebarPanes.watchExpressions.reset();delete this._skipExecutionLineRevealing;},_projectWillReset:function(event)
1183 {var project=event.data;var uiSourceCodes=project.uiSourceCodes();this._removeUISourceCodes(uiSourceCodes);if(project.type()===WebInspector.projectTypes.Network)
1184 this._editorContainer.reset();},get visibleView()
1185 {return this._editorContainer.visibleView;},_updateScriptViewStatusBarItems:function()
1186 {this._scriptViewStatusBarItemsContainer.removeChildren();this._scriptViewStatusBarTextContainer.removeChildren();var sourceFrame=this.visibleView;if(sourceFrame){var statusBarItems=sourceFrame.statusBarItems()||[];for(var i=0;i<statusBarItems.length;++i)
1187 this._scriptViewStatusBarItemsContainer.appendChild(statusBarItems[i]);var statusBarText=sourceFrame.statusBarText();if(statusBarText)
1188 this._scriptViewStatusBarTextContainer.appendChild(statusBarText);}},showAnchorLocation:function(anchor)
1189 {if(!anchor.uiSourceCode){var uiSourceCode=WebInspector.workspace.uiSourceCodeForURL(anchor.href);if(uiSourceCode)
1190 anchor.uiSourceCode=uiSourceCode;}
1191 if(!anchor.uiSourceCode)
1192 return false;this._showSourceLocation(anchor.uiSourceCode,anchor.lineNumber,anchor.columnNumber);return true;},showUISourceCode:function(uiSourceCode,lineNumber,columnNumber,forceShowInPanel)
1193 {this._showSourceLocation(uiSourceCode,lineNumber,columnNumber,forceShowInPanel);},_showEditor:function(forceShowInPanel)
1194 {if(this.sourcesView.isShowing())
1195 return;if(this._canShowEditorInDrawer()&&!forceShowInPanel){var drawerEditorView=new WebInspector.DrawerEditorView();this.sourcesView.show(drawerEditorView.element);WebInspector.inspectorView.showCloseableViewInDrawer("editor",WebInspector.UIString("Editor"),drawerEditorView);}else{WebInspector.showPanel("sources");}},currentUISourceCode:function()
1196 {return this._currentUISourceCode;},showUILocation:function(uiLocation,forceShowInPanel)
1197 {this._showSourceLocation(uiLocation.uiSourceCode,uiLocation.lineNumber,uiLocation.columnNumber,forceShowInPanel);},_canShowEditorInDrawer:function()
1198 {return WebInspector.experimentsSettings.showEditorInDrawer.isEnabled()&&WebInspector.settings.showEditorInDrawer.get();},_showSourceLocation:function(uiSourceCode,lineNumber,columnNumber,forceShowInPanel)
1199 {this._showEditor(forceShowInPanel);this._historyManager.updateCurrentState();var sourceFrame=this._showFile(uiSourceCode);if(typeof lineNumber==="number")
1200 sourceFrame.highlightPosition(lineNumber,columnNumber);this._historyManager.pushNewState();sourceFrame.focus();WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.OpenSourceLink,url:uiSourceCode.originURL(),lineNumber:lineNumber});},_showFile:function(uiSourceCode)
1201 {var sourceFrame=this._getOrCreateSourceFrame(uiSourceCode);if(this._currentUISourceCode===uiSourceCode)
1202 return sourceFrame;this._currentUISourceCode=uiSourceCode;if(!uiSourceCode.project().isServiceProject())
1203 this._navigator.revealUISourceCode(uiSourceCode,true);this._editorContainer.showFile(uiSourceCode);this._updateScriptViewStatusBarItems();if(this._currentUISourceCode.project().type()===WebInspector.projectTypes.Snippets)
1204 this._runSnippetButton.element.classList.remove("hidden");else
1205 this._runSnippetButton.element.classList.add("hidden");return sourceFrame;},_createSourceFrame:function(uiSourceCode)
1206 {var sourceFrame;switch(uiSourceCode.contentType()){case WebInspector.resourceTypes.Script:sourceFrame=new WebInspector.JavaScriptSourceFrame(this,uiSourceCode);break;case WebInspector.resourceTypes.Document:sourceFrame=new WebInspector.JavaScriptSourceFrame(this,uiSourceCode);break;case WebInspector.resourceTypes.Stylesheet:sourceFrame=new WebInspector.CSSSourceFrame(uiSourceCode);break;default:sourceFrame=new WebInspector.UISourceCodeFrame(uiSourceCode);break;}
1207 sourceFrame.setHighlighterType(uiSourceCode.highlighterType());this._sourceFramesByUISourceCode.put(uiSourceCode,sourceFrame);this._historyManager.trackSourceFrameCursorJumps(sourceFrame);return sourceFrame;},_getOrCreateSourceFrame:function(uiSourceCode)
1208 {return this._sourceFramesByUISourceCode.get(uiSourceCode)||this._createSourceFrame(uiSourceCode);},_sourceFrameMatchesUISourceCode:function(sourceFrame,uiSourceCode)
1209 {switch(uiSourceCode.contentType()){case WebInspector.resourceTypes.Script:case WebInspector.resourceTypes.Document:return sourceFrame instanceof WebInspector.JavaScriptSourceFrame;case WebInspector.resourceTypes.Stylesheet:return sourceFrame instanceof WebInspector.CSSSourceFrame;default:return!(sourceFrame instanceof WebInspector.JavaScriptSourceFrame);}},_recreateSourceFrameIfNeeded:function(uiSourceCode)
1210 {var oldSourceFrame=this._sourceFramesByUISourceCode.get(uiSourceCode);if(!oldSourceFrame)
1211 return;if(this._sourceFrameMatchesUISourceCode(oldSourceFrame,uiSourceCode)){oldSourceFrame.setHighlighterType(uiSourceCode.highlighterType());}else{this._editorContainer.removeUISourceCode(uiSourceCode);this._removeSourceFrame(uiSourceCode);}},viewForFile:function(uiSourceCode)
1212 {return this._getOrCreateSourceFrame(uiSourceCode);},_removeSourceFrame:function(uiSourceCode)
1213 {var sourceFrame=this._sourceFramesByUISourceCode.get(uiSourceCode);if(!sourceFrame)
1214 return;this._sourceFramesByUISourceCode.remove(uiSourceCode);sourceFrame.dispose();},_clearCurrentExecutionLine:function()
1215 {if(this._executionSourceFrame)
1216 this._executionSourceFrame.clearExecutionLine();delete this._executionSourceFrame;},_setExecutionLine:function(uiLocation)
1217 {var callFrame=WebInspector.debuggerModel.selectedCallFrame()
1218 var sourceFrame=this._getOrCreateSourceFrame(uiLocation.uiSourceCode);sourceFrame.setExecutionLine(uiLocation.lineNumber,callFrame);this._executionSourceFrame=sourceFrame;},_executionLineChanged:function(uiLocation)
1219 {this._historyManager.updateCurrentState();this._clearCurrentExecutionLine();this._setExecutionLine(uiLocation);var uiSourceCode=uiLocation.uiSourceCode;var scriptFile=this._currentUISourceCode?this._currentUISourceCode.scriptFile():null;if(this._skipExecutionLineRevealing)
1220 return;this._skipExecutionLineRevealing=true;var sourceFrame=this._showFile(uiSourceCode);sourceFrame.revealLine(uiLocation.lineNumber);this._historyManager.pushNewState();if(sourceFrame.canEditSource())
1221 sourceFrame.setSelection(WebInspector.TextRange.createFromLocation(uiLocation.lineNumber,0));sourceFrame.focus();},_callFrameSelected:function(event)
1222 {var callFrame=event.data;if(!callFrame)
1223 return;this.sidebarPanes.scopechain.update(callFrame);this.sidebarPanes.watchExpressions.refreshExpressions();this.sidebarPanes.callstack.setSelectedCallFrame(callFrame);callFrame.createLiveLocation(this._executionLineChanged.bind(this));},_editorClosed:function(event)
1224 {this._navigatorController.hideNavigatorOverlay();var uiSourceCode=(event.data);this._historyManager.removeHistoryForSourceCode(uiSourceCode);if(this._currentUISourceCode===uiSourceCode)
1225 delete this._currentUISourceCode;this._updateScriptViewStatusBarItems();this._searchableView.resetSearch();},_editorSelected:function(event)
1226 {var uiSourceCode=(event.data.currentFile);var shouldUseHistoryManager=uiSourceCode!==this._currentUISourceCode&&event.data.userGesture;if(shouldUseHistoryManager)
1227 this._historyManager.updateCurrentState();var sourceFrame=this._showFile(uiSourceCode);if(shouldUseHistoryManager)
1228 this._historyManager.pushNewState();this._navigatorController.hideNavigatorOverlay();if(!this._navigatorController.isNavigatorPinned())
1229 sourceFrame.focus();this._searchableView.setReplaceable(!!sourceFrame&&sourceFrame.canEditSource());this._searchableView.resetSearch();},_sourceSelected:function(event)
1230 {var uiSourceCode=(event.data.uiSourceCode);var shouldUseHistoryManager=uiSourceCode!==this._currentUISourceCode;if(shouldUseHistoryManager)
1231 this._historyManager.updateCurrentState();var sourceFrame=this._showFile(uiSourceCode);if(shouldUseHistoryManager)
1232 this._historyManager.pushNewState();this._navigatorController.hideNavigatorOverlay();if(sourceFrame&&(!this._navigatorController.isNavigatorPinned()||event.data.focusSource))
1233 sourceFrame.focus();},_itemSearchStarted:function(event)
1234 {var searchText=(event.data);WebInspector.OpenResourceDialog.show(this,this.editorView.mainElement(),searchText);},_createPauseOnExceptionOptions:function()
1235 {this._pauseOnExceptionButton.title=this._pauseOnExceptionStateTitle(this._pauseOnExceptionButton.state);var excludedOption=this._pauseOnExceptionButton.state;var pauseStates=WebInspector.SourcesPanel.PauseOnExceptionsStates.slice(0);var options=[];for(var i=0;i<pauseStates.length;++i){if(pauseStates[i]===excludedOption)
1236 continue;var button=new WebInspector.StatusBarButton("","scripts-pause-on-exceptions-status-bar-item",3);button.addEventListener("click",this._togglePauseOnExceptions,this);button.state=pauseStates[i];button.title=this._pauseOnExceptionStateTitle(pauseStates[i]);options.push(button);}
1237 return options;},_pauseOnExceptionStateChanged:function()
1238 {var state=WebInspector.settings.pauseOnExceptionStateString.get();var nextState;if(state===WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions)
1239 nextState=WebInspector.settings.lastPauseOnExceptionState.get();else
1240 nextState=WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions;this._pauseOnExceptionButton.title=this._pauseOnExceptionStateTitle(state,nextState);this._pauseOnExceptionButton.state=state;},_pauseOnExceptionStateTitle:function(state,nextState)
1241 {var states=WebInspector.DebuggerModel.PauseOnExceptionsState;var stateDescription;if(state===states.DontPauseOnExceptions){stateDescription=WebInspector.UIString("Don't pause on exceptions.");}else if(state===states.PauseOnAllExceptions){stateDescription=WebInspector.UIString("Pause on exceptions, including caught exceptions.");}else if(state===states.PauseOnUncaughtExceptions){stateDescription=WebInspector.UIString("Pause on exceptions.");}else{throw"Unexpected state: "+state;}
1242 var nextStateDescription;if(nextState===states.DontPauseOnExceptions){nextStateDescription=WebInspector.UIString("Click to Not pause on exceptions.");}else if(nextState===states.PauseOnAllExceptions){nextStateDescription=WebInspector.UIString("Click to Pause on exceptions, including caught exceptions.");}else if(nextState===states.PauseOnUncaughtExceptions){nextStateDescription=WebInspector.UIString("Click to Pause on exceptions.");}
1243 return nextState?String.sprintf("%s\n%s",stateDescription,nextStateDescription):stateDescription;},_updateDebuggerButtons:function()
1244 {if(this._paused){this._updateButtonTitle(this._pauseButton,WebInspector.UIString("Resume script execution (%s)."))
1245 this._pauseButton.state=true;this._pauseButton.setLongClickOptionsEnabled((function(){return[this._longResumeButton]}).bind(this));this._pauseButton.setEnabled(true);this._stepOverButton.setEnabled(true);this._stepIntoButton.setEnabled(true);this._stepOutButton.setEnabled(true);}else{this._updateButtonTitle(this._pauseButton,WebInspector.UIString("Pause script execution (%s)."))
1246 this._pauseButton.state=false;this._pauseButton.setLongClickOptionsEnabled(null);this._pauseButton.setEnabled(!this._waitingToPause);this._stepOverButton.setEnabled(false);this._stepIntoButton.setEnabled(false);this._stepOutButton.setEnabled(false);}},_clearInterface:function()
1247 {this.sidebarPanes.callstack.update(null,null);this.sidebarPanes.scopechain.update(null);this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();WebInspector.domBreakpointsSidebarPane.clearBreakpointHighlight();this.sidebarPanes.eventListenerBreakpoints.clearBreakpointHighlight();this.sidebarPanes.xhrBreakpoints.clearBreakpointHighlight();this._clearCurrentExecutionLine();this._updateDebuggerButtons();},_togglePauseOnExceptions:function(e)
1248 {var target=(e.target);var state=(target.state);var toggle=!e.data;var stateEnum=WebInspector.DebuggerModel.PauseOnExceptionsState;if(toggle){if(state!==stateEnum.DontPauseOnExceptions)
1249 state=stateEnum.DontPauseOnExceptions
1250 else
1251 state=WebInspector.settings.lastPauseOnExceptionState.get();}
1252 if(state!==stateEnum.DontPauseOnExceptions)
1253 WebInspector.settings.lastPauseOnExceptionState.set(state);WebInspector.settings.pauseOnExceptionStateString.set(state);},_runSnippet:function()
1254 {if(this._currentUISourceCode.project().type()!==WebInspector.projectTypes.Snippets)
1255 return false;WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISourceCode);return true;},_togglePause:function()
1256 {if(this._paused){delete this._skipExecutionLineRevealing;this._paused=false;this._waitingToPause=false;WebInspector.debuggerModel.resume();}else{this._stepping=false;this._waitingToPause=true;WebInspector.debuggerModel.skipAllPauses(false);DebuggerAgent.pause();}
1257 this._clearInterface();return true;},_longResume:function()
1258 {if(!this._paused)
1259 return true;this._paused=false;this._waitingToPause=false;WebInspector.debuggerModel.skipAllPausesUntilReloadOrTimeout(500);WebInspector.debuggerModel.resume();this._clearInterface();return true;},_stepOverClicked:function()
1260 {if(!this._paused)
1261 return true;delete this._skipExecutionLineRevealing;this._paused=false;this._stepping=true;this._clearInterface();WebInspector.debuggerModel.stepOver();return true;},_stepIntoClicked:function()
1262 {if(!this._paused)
1263 return true;delete this._skipExecutionLineRevealing;this._paused=false;this._stepping=true;this._clearInterface();WebInspector.debuggerModel.stepInto();return true;},_stepIntoSelectionClicked:function(event)
1264 {if(!this._paused)
1265 return true;if(this._executionSourceFrame){var stepIntoMarkup=this._executionSourceFrame.stepIntoMarkup();if(stepIntoMarkup)
1266 stepIntoMarkup.iterateSelection(event.shiftKey);}
1267 return true;},doStepIntoSelection:function(rawLocation)
1268 {if(!this._paused)
1269 return;delete this._skipExecutionLineRevealing;this._paused=false;this._stepping=true;this._clearInterface();WebInspector.debuggerModel.stepIntoSelection(rawLocation);},_stepOutClicked:function()
1270 {if(!this._paused)
1271 return true;delete this._skipExecutionLineRevealing;this._paused=false;this._stepping=true;this._clearInterface();WebInspector.debuggerModel.stepOut();return true;},_callFrameSelectedInSidebar:function(event)
1272 {var callFrame=(event.data);delete this._skipExecutionLineRevealing;WebInspector.debuggerModel.setSelectedCallFrame(callFrame);},_callFrameRestartedInSidebar:function()
1273 {delete this._skipExecutionLineRevealing;},continueToLocation:function(rawLocation)
1274 {if(!this._paused)
1275 return;delete this._skipExecutionLineRevealing;this._paused=false;this._stepping=true;this._clearInterface();WebInspector.debuggerModel.continueToLocation(rawLocation);},_toggleBreakpointsClicked:function(event)
1276 {WebInspector.debuggerModel.setBreakpointsActive(!WebInspector.debuggerModel.breakpointsActive());},_breakpointsActiveStateChanged:function(event)
1277 {var active=event.data;this._toggleBreakpointsButton.toggled=!active;if(active){this._toggleBreakpointsButton.title=WebInspector.UIString("Deactivate breakpoints.");this._editorContainer.view.element.classList.remove("breakpoints-deactivated");this.sidebarPanes.jsBreakpoints.listElement.classList.remove("breakpoints-list-deactivated");}else{this._toggleBreakpointsButton.title=WebInspector.UIString("Activate breakpoints.");this._editorContainer.view.element.classList.add("breakpoints-deactivated");this.sidebarPanes.jsBreakpoints.listElement.classList.add("breakpoints-list-deactivated");}},_createDebugToolbar:function()
1278 {var debugToolbar=document.createElement("div");debugToolbar.className="status-bar";debugToolbar.id="scripts-debug-toolbar";var title,handler;var platformSpecificModifier=WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta;title=WebInspector.UIString("Run snippet (%s).");handler=this._runSnippet.bind(this);this._runSnippetButton=this._createButtonAndRegisterShortcuts("scripts-run-snippet",title,handler,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.RunSnippet);debugToolbar.appendChild(this._runSnippetButton.element);this._runSnippetButton.element.classList.add("hidden");handler=this._togglePause.bind(this);this._pauseButton=this._createButtonAndRegisterShortcuts("scripts-pause","",handler,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.PauseContinue);debugToolbar.appendChild(this._pauseButton.element);title=WebInspector.UIString("Resume with all pauses blocked for 500 ms");this._longResumeButton=new WebInspector.StatusBarButton(title,"scripts-long-resume");this._longResumeButton.addEventListener("click",this._longResume.bind(this),this);title=WebInspector.UIString("Step over next function call (%s).");handler=this._stepOverClicked.bind(this);this._stepOverButton=this._createButtonAndRegisterShortcuts("scripts-step-over",title,handler,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOver);debugToolbar.appendChild(this._stepOverButton.element);title=WebInspector.UIString("Step into next function call (%s).");handler=this._stepIntoClicked.bind(this);this._stepIntoButton=this._createButtonAndRegisterShortcuts("scripts-step-into",title,handler,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepInto);debugToolbar.appendChild(this._stepIntoButton.element);this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepIntoSelection,this._stepIntoSelectionClicked.bind(this))
1279 title=WebInspector.UIString("Step out of current function (%s).");handler=this._stepOutClicked.bind(this);this._stepOutButton=this._createButtonAndRegisterShortcuts("scripts-step-out",title,handler,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.StepOut);debugToolbar.appendChild(this._stepOutButton.element);this._toggleBreakpointsButton=new WebInspector.StatusBarButton(WebInspector.UIString("Deactivate breakpoints."),"scripts-toggle-breakpoints");this._toggleBreakpointsButton.toggled=false;this._toggleBreakpointsButton.addEventListener("click",this._toggleBreakpointsClicked,this);debugToolbar.appendChild(this._toggleBreakpointsButton.element);this._pauseOnExceptionButton=new WebInspector.StatusBarButton("","scripts-pause-on-exceptions-status-bar-item",3);this._pauseOnExceptionButton.addEventListener("click",this._togglePauseOnExceptions,this);this._pauseOnExceptionButton.setLongClickOptionsEnabled(this._createPauseOnExceptionOptions.bind(this));debugToolbar.appendChild(this._pauseOnExceptionButton.element);return debugToolbar;},_updateButtonTitle:function(button,buttonTitle)
1280 {var hasShortcuts=button.shortcuts&&button.shortcuts.length;if(hasShortcuts)
1281 button.title=String.vsprintf(buttonTitle,[button.shortcuts[0].name]);else
1282 button.title=buttonTitle;},_createButtonAndRegisterShortcuts:function(buttonId,buttonTitle,handler,shortcuts)
1283 {var button=new WebInspector.StatusBarButton(buttonTitle,buttonId);button.element.addEventListener("click",handler,false);button.shortcuts=shortcuts;this._updateButtonTitle(button,buttonTitle);this.registerShortcuts(shortcuts,handler);return button;},searchCanceled:function()
1284 {if(this._searchView)
1285 this._searchView.searchCanceled();delete this._searchView;delete this._searchQuery;},performSearch:function(query,shouldJump)
1286 {this._searchableView.updateSearchMatchesCount(0);if(!this.visibleView)
1287 return;this._searchView=this.visibleView;this._searchQuery=query;function finishedCallback(view,searchMatches)
1288 {if(!searchMatches)
1289 return;this._searchableView.updateSearchMatchesCount(searchMatches);}
1290 function currentMatchChanged(currentMatchIndex)
1291 {this._searchableView.updateCurrentMatchIndex(currentMatchIndex);}
1292 function searchResultsChanged()
1293 {this._searchableView.cancelSearch();}
1294 this._searchView.performSearch(query,shouldJump,finishedCallback.bind(this),currentMatchChanged.bind(this),searchResultsChanged.bind(this));},jumpToNextSearchResult:function()
1295 {if(!this._searchView)
1296 return;if(this._searchView!==this.visibleView){this.performSearch(this._searchQuery,true);return;}
1297 this._searchView.jumpToNextSearchResult();},jumpToPreviousSearchResult:function()
1298 {if(!this._searchView)
1299 return;if(this._searchView!==this.visibleView){this.performSearch(this._searchQuery,true);if(this._searchView)
1300 this._searchView.jumpToLastSearchResult();return;}
1301 this._searchView.jumpToPreviousSearchResult();},replaceSelectionWith:function(text)
1302 {var view=(this.visibleView);view.replaceSelectionWith(text);},replaceAllWith:function(query,text)
1303 {var view=(this.visibleView);view.replaceAllWith(query,text);},_onKeyDown:function(event)
1304 {if(event.keyCode!==WebInspector.KeyboardShortcut.Keys.CtrlOrMeta.code)
1305 return;if(!this._paused||!this._executionSourceFrame)
1306 return;var stepIntoMarkup=this._executionSourceFrame.stepIntoMarkup();if(stepIntoMarkup)
1307 stepIntoMarkup.startIteratingSelection();},_onKeyUp:function(event)
1308 {if(event.keyCode!==WebInspector.KeyboardShortcut.Keys.CtrlOrMeta.code)
1309 return;if(!this._paused||!this._executionSourceFrame)
1310 return;var stepIntoMarkup=this._executionSourceFrame.stepIntoMarkup();if(!stepIntoMarkup)
1311 return;var currentPosition=stepIntoMarkup.getSelectedItemIndex();if(typeof currentPosition==="undefined"){stepIntoMarkup.stopIteratingSelection();}else{var rawLocation=stepIntoMarkup.getRawPosition(currentPosition);this.doStepIntoSelection(rawLocation);}},_toggleFormatSource:function()
1312 {delete this._skipExecutionLineRevealing;this._toggleFormatSourceButton.toggled=!this._toggleFormatSourceButton.toggled;var uiSourceCodes=this._workspace.uiSourceCodes();for(var i=0;i<uiSourceCodes.length;++i)
1313 uiSourceCodes[i].setFormatted(this._toggleFormatSourceButton.toggled);var currentFile=this._editorContainer.currentFile();WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.TogglePrettyPrint,enabled:this._toggleFormatSourceButton.toggled,url:currentFile?currentFile.originURL():null});},addToWatch:function(expression)
1314 {this.sidebarPanes.watchExpressions.addExpression(expression);},_toggleBreakpoint:function()
1315 {var sourceFrame=this.visibleView;if(!sourceFrame)
1316 return false;if(sourceFrame instanceof WebInspector.JavaScriptSourceFrame){var javaScriptSourceFrame=(sourceFrame);javaScriptSourceFrame.toggleBreakpointOnCurrentLine();return true;}
1317 return false;},_showOutlineDialog:function(event)
1318 {var uiSourceCode=this._editorContainer.currentFile();if(!uiSourceCode)
1319 return false;switch(uiSourceCode.contentType()){case WebInspector.resourceTypes.Document:case WebInspector.resourceTypes.Script:WebInspector.JavaScriptOutlineDialog.show(this.visibleView,uiSourceCode,this.highlightPosition.bind(this));return true;case WebInspector.resourceTypes.Stylesheet:WebInspector.StyleSheetOutlineDialog.show(this.visibleView,uiSourceCode,this.highlightPosition.bind(this));return true;}
1320 return false;},_installDebuggerSidebarController:function()
1321 {this._toggleDebuggerSidebarButton=new WebInspector.StatusBarButton("","right-sidebar-show-hide-button scripts-debugger-show-hide-button",3);this._toggleDebuggerSidebarButton.addEventListener("click",clickHandler,this);if(this.splitView.isVertical()){this.editorView.element.appendChild(this._toggleDebuggerSidebarButton.element);this.splitView.mainElement().appendChild(this._debugSidebarResizeWidgetElement);}else{this._statusBarContainerElement.appendChild(this._debugSidebarResizeWidgetElement);this._statusBarContainerElement.appendChild(this._toggleDebuggerSidebarButton.element);}
1322 this._enableDebuggerSidebar(!WebInspector.settings.debuggerSidebarHidden.get());function clickHandler()
1323 {this._enableDebuggerSidebar(this._toggleDebuggerSidebarButton.state==="left");}},_enableDebuggerSidebar:function(show)
1324 {this._toggleDebuggerSidebarButton.state=show?"right":"left";this._toggleDebuggerSidebarButton.title=show?WebInspector.UIString("Hide debugger"):WebInspector.UIString("Show debugger");if(show)
1325 this.splitView.showSidebarElement();else
1326 this.splitView.hideSidebarElement();this._debugSidebarResizeWidgetElement.enableStyleClass("hidden",!show);WebInspector.settings.debuggerSidebarHidden.set(!show);},_itemCreationRequested:function(event)
1327 {var project=event.data.project;var path=event.data.path;var uiSourceCodeToCopy=event.data.uiSourceCode;var filePath;var shouldHideNavigator;var uiSourceCode;function contentLoaded(content)
1328 {createFile.call(this,content||"");}
1329 if(uiSourceCodeToCopy)
1330 uiSourceCodeToCopy.requestContent(contentLoaded.bind(this));else
1331 createFile.call(this);function createFile(content)
1332 {project.createFile(path,null,content||"",fileCreated.bind(this));}
1333 function fileCreated(path)
1334 {if(!path)
1335 return;filePath=path;uiSourceCode=project.uiSourceCode(filePath);this._showSourceLocation(uiSourceCode);shouldHideNavigator=!this._navigatorController.isNavigatorPinned();if(this._navigatorController.isNavigatorHidden())
1336 this._navigatorController.showNavigatorOverlay();this._navigator.rename(uiSourceCode,callback.bind(this));}
1337 function callback(committed)
1338 {if(shouldHideNavigator)
1339 this._navigatorController.hideNavigatorOverlay();if(!committed){project.deleteFile(uiSourceCode);return;}
1340 this._recreateSourceFrameIfNeeded(uiSourceCode);this._navigator.updateIcon(uiSourceCode);this._showSourceLocation(uiSourceCode);}},_itemRenamingRequested:function(event)
1341 {var uiSourceCode=(event.data);var shouldHideNavigator=!this._navigatorController.isNavigatorPinned();if(this._navigatorController.isNavigatorHidden())
1342 this._navigatorController.showNavigatorOverlay();this._navigator.rename(uiSourceCode,callback.bind(this));function callback(committed)
1343 {if(shouldHideNavigator&&committed)
1344 this._navigatorController.hideNavigatorOverlay();this._recreateSourceFrameIfNeeded(uiSourceCode);this._navigator.updateIcon(uiSourceCode);this._showSourceLocation(uiSourceCode);}},_showLocalHistory:function(uiSourceCode)
1345 {WebInspector.RevisionHistoryView.showHistory(uiSourceCode);},appendApplicableItems:function(event,contextMenu,target)
1346 {this._appendUISourceCodeItems(contextMenu,target);this._appendFunctionItems(contextMenu,target);},_mapFileSystemToNetwork:function(uiSourceCode)
1347 {WebInspector.SelectUISourceCodeForProjectTypeDialog.show(uiSourceCode.name(),WebInspector.projectTypes.Network,mapFileSystemToNetwork.bind(this),this.editorView.mainElement())
1348 function mapFileSystemToNetwork(networkUISourceCode)
1349 {this._workspace.addMapping(networkUISourceCode,uiSourceCode,WebInspector.fileSystemWorkspaceProvider);}},_removeNetworkMapping:function(uiSourceCode)
1350 {if(confirm(WebInspector.UIString("Are you sure you want to remove network mapping?")))
1351 this._workspace.removeMapping(uiSourceCode);},_mapNetworkToFileSystem:function(networkUISourceCode)
1352 {WebInspector.SelectUISourceCodeForProjectTypeDialog.show(networkUISourceCode.name(),WebInspector.projectTypes.FileSystem,mapNetworkToFileSystem.bind(this),this.editorView.mainElement())
1353 function mapNetworkToFileSystem(uiSourceCode)
1354 {this._workspace.addMapping(networkUISourceCode,uiSourceCode,WebInspector.fileSystemWorkspaceProvider);}},_appendUISourceCodeMappingItems:function(contextMenu,uiSourceCode)
1355 {if(uiSourceCode.project().type()===WebInspector.projectTypes.FileSystem){var hasMappings=!!uiSourceCode.url;if(!hasMappings)
1356 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Map to network resource\u2026":"Map to Network Resource\u2026"),this._mapFileSystemToNetwork.bind(this,uiSourceCode));else
1357 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove network mapping":"Remove Network Mapping"),this._removeNetworkMapping.bind(this,uiSourceCode));}
1358 function filterProject(project)
1359 {return project.type()===WebInspector.projectTypes.FileSystem;}
1360 if(uiSourceCode.project().type()===WebInspector.projectTypes.Network){if(!this._workspace.projects().filter(filterProject).length)
1361 return;if(this._workspace.uiSourceCodeForURL(uiSourceCode.url)===uiSourceCode)
1362 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Map to file system resource\u2026":"Map to File System Resource\u2026"),this._mapNetworkToFileSystem.bind(this,uiSourceCode));}},_appendUISourceCodeItems:function(contextMenu,target)
1363 {if(!(target instanceof WebInspector.UISourceCode))
1364 return;var uiSourceCode=(target);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Local modifications\u2026":"Local Modifications\u2026"),this._showLocalHistory.bind(this,uiSourceCode));if(WebInspector.isolatedFileSystemManager.supportsFileSystems())
1365 this._appendUISourceCodeMappingItems(contextMenu,uiSourceCode);},_appendFunctionItems:function(contextMenu,target)
1366 {if(!(target instanceof WebInspector.RemoteObject))
1367 return;var remoteObject=(target);if(remoteObject.type!=="function")
1368 return;function didGetDetails(error,response)
1369 {if(error){console.error(error);return;}
1370 var uiLocation=WebInspector.debuggerModel.rawLocationToUILocation(response.location);if(!uiLocation)
1371 return;this.showUILocation(uiLocation,true);}
1372 function revealFunction()
1373 {DebuggerAgent.getFunctionDetails(remoteObject.objectId,didGetDetails.bind(this));}
1374 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Show function definition":"Show Function Definition"),revealFunction.bind(this));},showGoToSourceDialog:function()
1375 {var uiSourceCodes=this._editorContainer.historyUISourceCodes();var defaultScores=new Map();for(var i=1;i<uiSourceCodes.length;++i)
1376 defaultScores.put(uiSourceCodes[i],uiSourceCodes.length-i);WebInspector.OpenResourceDialog.show(this,this.editorView.mainElement(),undefined,defaultScores);},_dockSideChanged:function()
1377 {var dockSide=WebInspector.dockController.dockSide();var vertically=dockSide===WebInspector.DockController.State.DockedToRight&&WebInspector.settings.splitVerticallyWhenDockedToRight.get();this._splitVertically(vertically);},_splitVertically:function(vertically)
1378 {if(this.sidebarPaneView&&vertically===!this.splitView.isVertical())
1379 return;if(this.sidebarPaneView)
1380 this.sidebarPaneView.detach();this.splitView.setVertical(!vertically);if(!vertically){this.splitView.uninstallResizer(this._statusBarContainerElement);this.sidebarPaneView=new WebInspector.SidebarPaneStack();for(var pane in this.sidebarPanes)
1381 this.sidebarPaneView.addPane(this.sidebarPanes[pane]);this._extensionSidebarPanesContainer=this.sidebarPaneView;this.splitView.sidebarElement().appendChild(this.debugToolbar);this.editorView.element.appendChild(this._toggleDebuggerSidebarButton.element);this.splitView.mainElement().appendChild(this._debugSidebarResizeWidgetElement);}else{this.splitView.installResizer(this._statusBarContainerElement);this.sidebarPaneView=new WebInspector.SplitView(true,this.name+"PanelSplitSidebarRatio",0.5);var group1=new WebInspector.SidebarPaneStack();this.sidebarPaneView.setFirstView(group1);group1.element.id="scripts-sidebar-stack-pane";group1.addPane(this.sidebarPanes.callstack);group1.addPane(this.sidebarPanes.jsBreakpoints);group1.addPane(this.sidebarPanes.domBreakpoints);group1.addPane(this.sidebarPanes.xhrBreakpoints);group1.addPane(this.sidebarPanes.eventListenerBreakpoints);if(this.sidebarPanes.workerList)
1382 group1.addPane(this.sidebarPanes.workerList);var group2=new WebInspector.SidebarTabbedPane();this.sidebarPaneView.setSecondView(group2);group2.addPane(this.sidebarPanes.scopechain);group2.addPane(this.sidebarPanes.watchExpressions);this._extensionSidebarPanesContainer=group2;this.sidebarPaneView.firstElement().appendChild(this.debugToolbar);this._statusBarContainerElement.appendChild(this._debugSidebarResizeWidgetElement);this._statusBarContainerElement.appendChild(this._toggleDebuggerSidebarButton.element)}
1383 for(var i=0;i<this._extensionSidebarPanes.length;++i)
1384 this._extensionSidebarPanesContainer.addPane(this._extensionSidebarPanes[i]);this.sidebarPaneView.element.id="scripts-debug-sidebar-contents";this.splitView.setSidebarView(this.sidebarPaneView);this.sidebarPanes.scopechain.expand();this.sidebarPanes.jsBreakpoints.expand();this.sidebarPanes.callstack.expand();if(WebInspector.settings.watchExpressions.get().length>0)
1385 this.sidebarPanes.watchExpressions.expand();},canHighlightPosition:function()
1386 {return this.visibleView&&this.visibleView.canHighlightPosition();},highlightPosition:function(line,column)
1387 {if(!this.canHighlightPosition())
1388 return;this._historyManager.updateCurrentState();this.visibleView.highlightPosition(line,column);this._historyManager.pushNewState();},addExtensionSidebarPane:function(id,pane)
1389 {this._extensionSidebarPanes.push(pane);this._extensionSidebarPanesContainer.addPane(pane);this.setHideOnDetach();},get tabbedEditorContainer()
1390 {return this._editorContainer;},__proto__:WebInspector.Panel.prototype}
1391 WebInspector.SourcesView=function()
1392 {WebInspector.View.call(this);this.registerRequiredCSS("sourcesView.css");this.element.id="sources-panel-sources-view";this.element.classList.add("vbox");this.element.addEventListener("dragenter",this._onDragEnter.bind(this),true);this.element.addEventListener("dragover",this._onDragOver.bind(this),true);}
1393 WebInspector.SourcesView.dragAndDropFilesType="Files";WebInspector.SourcesView.prototype={_onDragEnter:function(event)
1394 {if(event.dataTransfer.types.indexOf(WebInspector.SourcesView.dragAndDropFilesType)===-1)
1395 return;event.consume(true);},_onDragOver:function(event)
1396 {if(event.dataTransfer.types.indexOf(WebInspector.SourcesView.dragAndDropFilesType)===-1)
1397 return;event.consume(true);if(this._dragMaskElement)
1398 return;this._dragMaskElement=this.element.createChild("div","fill drag-mask");this._dragMaskElement.addEventListener("drop",this._onDrop.bind(this),true);this._dragMaskElement.addEventListener("dragleave",this._onDragLeave.bind(this),true);},_onDrop:function(event)
1399 {event.consume(true);this._removeMask();var items=(event.dataTransfer.items);if(!items.length)
1400 return;var entry=items[0].webkitGetAsEntry();if(!entry.isDirectory)
1401 return;InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesystem);},_onDragLeave:function(event)
1402 {event.consume(true);this._removeMask();},_removeMask:function()
1403 {this._dragMaskElement.remove();delete this._dragMaskElement;},__proto__:WebInspector.View.prototype}
1404 WebInspector.DrawerEditorView=function()
1405 {WebInspector.View.call(this);this.element.id="drawer-editor-view";this.element.classList.add("vbox");}
1406 WebInspector.DrawerEditorView.prototype={__proto__:WebInspector.View.prototype}
1407 WebInspector.SourcesPanel.ContextMenuProvider=function()
1408 {}
1409 WebInspector.SourcesPanel.ContextMenuProvider.prototype={appendApplicableItems:function(event,contextMenu,target)
1410 {WebInspector.panel("sources").appendApplicableItems(event,contextMenu,target);}}