Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / SourcesPanel.js
1 WebInspector.JavaScriptBreakpointsSidebarPane=function(debuggerModel,breakpointManager,showSourceLineDelegate)
2 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Breakpoints"));this._debuggerModel=debuggerModel;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=this._debuggerModel.breakpointsActive();var breakpointActiveTitle=breakpointActive?WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Deactivate breakpoints":"Deactivate Breakpoints"):WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Activate breakpoints":"Activate Breakpoints");contextMenu.appendItem(breakpointActiveTitle,this._debuggerModel.setBreakpointsActive.bind(this._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 lineNumber=uiLocation.lineNumber
9 var columnNumber=uiLocation.columnNumber;var contentString=new String(content);if(lineNumber<contentString.lineCount()){var lineText=contentString.lineAt(lineNumber);var maxSnippetLength=200;snippetElement.textContent=lineText.substr(columnNumber).trimEnd(maxSnippetLength);}}
10 uiLocation.uiSourceCode.requestContent(didRequestContent);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=this._debuggerModel.breakpointsActive();var breakpointActiveTitle=breakpointActive?WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Deactivate breakpoints":"Deactivate Breakpoints"):WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Activate breakpoints":"Activate Breakpoints");contextMenu.appendItem(breakpointActiveTitle,this._debuggerModel.setBreakpointsActive.bind(this._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.InplaceEditor.Config(finishEditing.bind(this,true),finishEditing.bind(this,false));WebInspector.InplaceEditor.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.InplaceEditor.startEditing(inputElement,new WebInspector.InplaceEditor.Config(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("Drag / drop"),true,["dragenter","dragover","dragleave","drop"]);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","wheel"]);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.SettingsUI.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;if(title)
116 title+=" "+WebInspector.UIString("(async)");else
117 title=WebInspector.UIString("Async Call");var asyncPlacard=new WebInspector.Placard(title,"");asyncPlacard.element.classList.add("placard-label");this.bodyElement.appendChild(asyncPlacard.element);this._appendSidebarPlacards(asyncStackTrace.callFrames,asyncPlacard);asyncStackTrace=asyncStackTrace.asyncStackTrace;}},_appendSidebarPlacards:function(callFrames,asyncPlacard)
118 {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);}
119 this.placards.push(placard);this.bodyElement.appendChild(placard.element);}},_placardContextMenu:function(placard,event)
120 {var contextMenu=new WebInspector.ContextMenu(event);if(!placard._callFrame.isAsync())
121 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)
122 {placard._callFrame.restart();this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.CallFrameRestarted,placard._callFrame);},_asyncStackTracesStateChanged:function()
123 {var enabled=WebInspector.settings.enableAsyncStackTraces.get();if(!enabled&&this.placards)
124 this._removeAsyncPlacards();},_removeAsyncPlacards:function()
125 {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)
126 shouldSelectTopFrame=true;placard._asyncPlacard.element.remove();placard.element.remove();}else{lastSyncPlacardIndex=i;}}
127 this.placards.length=lastSyncPlacardIndex+1;if(shouldSelectTopFrame)
128 this._selectPlacardByIndex(0);},setSelectedCallFrame:function(x)
129 {for(var i=0;i<this.placards.length;++i){var placard=this.placards[i];placard.selected=(placard._callFrame===x);}},_selectNextCallFrameOnStack:function()
130 {var index=this._selectedCallFrameIndex();if(index===-1)
131 return false;return this._selectPlacardByIndex(index+1);},_selectPreviousCallFrameOnStack:function()
132 {var index=this._selectedCallFrameIndex();if(index===-1)
133 return false;return this._selectPlacardByIndex(index-1);},_selectPlacardByIndex:function(index)
134 {if(index<0||index>=this.placards.length)
135 return false;this._placardSelected(this.placards[index]);return true;},_selectedCallFrameIndex:function()
136 {var selectedCallFrame=WebInspector.debuggerModel.selectedCallFrame();if(!selectedCallFrame)
137 return-1;for(var i=0;i<this.placards.length;++i){var placard=this.placards[i];if(placard._callFrame===selectedCallFrame)
138 return i;}
139 return-1;},_placardSelected:function(placard)
140 {placard.element.scrollIntoViewIfNeeded();this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.CallFrameSelected,placard._callFrame);},_copyStackTrace:function()
141 {var text="";for(var i=0;i<this.placards.length;++i){if(i&&this.placards[i]._asyncPlacard!==this.placards[i-1]._asyncPlacard)
142 text+=this.placards[i]._asyncPlacard.title+"\n";text+=this.placards[i].title+" ("+this.placards[i].subtitle+")\n";}
143 InspectorFrontendHost.copyText(text);},registerShortcuts:function(registerShortcutDelegate)
144 {registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.NextCallFrame,this._selectNextCallFrameOnStack.bind(this));registerShortcutDelegate(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.PrevCallFrame,this._selectPreviousCallFrameOnStack.bind(this));},setStatus:function(status)
145 {if(!this._statusMessageElement)
146 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)
147 {if(event.altKey||event.shiftKey||event.metaKey||event.ctrlKey)
148 return;if(event.keyIdentifier==="Up"&&this._selectPreviousCallFrameOnStack()||event.keyIdentifier==="Down"&&this._selectNextCallFrameOnStack())
149 event.consume(true);},__proto__:WebInspector.SidebarPane.prototype}
150 WebInspector.CallStackSidebarPane.Placard=function(callFrame,asyncPlacard)
151 {WebInspector.Placard.call(this,callFrame.functionName||WebInspector.UIString("(anonymous function)"),"");callFrame.createLiveLocation(this._update.bind(this));this._callFrame=callFrame;this._asyncPlacard=asyncPlacard;}
152 WebInspector.CallStackSidebarPane.Placard.prototype={_update:function(uiLocation)
153 {this.subtitle=uiLocation.linkText().trimMiddle(100);},__proto__:WebInspector.Placard.prototype};WebInspector.HistoryEntry=function(){}
154 WebInspector.HistoryEntry.prototype={valid:function(){},reveal:function(){}};WebInspector.SimpleHistoryManager=function(historyDepth)
155 {this._entries=[];this._activeEntryIndex=-1;this._coalescingReadonly=0;this._historyDepth=historyDepth;}
156 WebInspector.SimpleHistoryManager.prototype={readOnlyLock:function()
157 {++this._coalescingReadonly;},releaseReadOnlyLock:function()
158 {--this._coalescingReadonly;},readOnly:function()
159 {return!!this._coalescingReadonly;},filterOut:function(filterOutCallback)
160 {if(this.readOnly())
161 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)
162 ++removedBeforeActiveEntry;}
163 this._entries=filteredEntries;this._activeEntryIndex=Math.max(0,this._activeEntryIndex-removedBeforeActiveEntry);},empty:function()
164 {return!this._entries.length;},active:function()
165 {return this.empty()?null:this._entries[this._activeEntryIndex];},push:function(entry)
166 {if(this.readOnly())
167 return;if(!this.empty())
168 this._entries.splice(this._activeEntryIndex+1);this._entries.push(entry);if(this._entries.length>this._historyDepth)
169 this._entries.shift();this._activeEntryIndex=this._entries.length-1;},rollback:function()
170 {if(this.empty())
171 return false;var revealIndex=this._activeEntryIndex-1;while(revealIndex>=0&&!this._entries[revealIndex].valid())
172 --revealIndex;if(revealIndex<0)
173 return false;this.readOnlyLock();this._entries[revealIndex].reveal();this.releaseReadOnlyLock();this._activeEntryIndex=revealIndex;return true;},rollover:function()
174 {var revealIndex=this._activeEntryIndex+1;while(revealIndex<this._entries.length&&!this._entries[revealIndex].valid())
175 ++revealIndex;if(revealIndex>=this._entries.length)
176 return false;this.readOnlyLock();this._entries[revealIndex].reveal();this.releaseReadOnlyLock();this._activeEntryIndex=revealIndex;return true;},};;WebInspector.EditingLocationHistoryManager=function(sourcesView,currentSourceFrameCallback)
177 {this._sourcesView=sourcesView;this._historyManager=new WebInspector.SimpleHistoryManager(WebInspector.EditingLocationHistoryManager.HistoryDepth);this._currentSourceFrameCallback=currentSourceFrameCallback;}
178 WebInspector.EditingLocationHistoryManager.HistoryDepth=20;WebInspector.EditingLocationHistoryManager.prototype={trackSourceFrameCursorJumps:function(sourceFrame)
179 {sourceFrame.addEventListener(WebInspector.SourceFrame.Events.JumpHappened,this._onJumpHappened.bind(this));},_onJumpHappened:function(event)
180 {if(event.data.from)
181 this._updateActiveState(event.data.from);if(event.data.to)
182 this._pushActiveState(event.data.to);},rollback:function()
183 {this._historyManager.rollback();},rollover:function()
184 {this._historyManager.rollover();},updateCurrentState:function()
185 {var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
186 return;this._updateActiveState(sourceFrame.textEditor.selection());},pushNewState:function()
187 {var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
188 return;this._pushActiveState(sourceFrame.textEditor.selection());},_updateActiveState:function(selection)
189 {var active=this._historyManager.active();if(!active)
190 return;var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
191 return;var entry=new WebInspector.EditingLocationHistoryEntry(this._sourcesView,this,sourceFrame,selection);active.merge(entry);},_pushActiveState:function(selection)
192 {var sourceFrame=this._currentSourceFrameCallback();if(!sourceFrame)
193 return;var entry=new WebInspector.EditingLocationHistoryEntry(this._sourcesView,this,sourceFrame,selection);this._historyManager.push(entry);},removeHistoryForSourceCode:function(uiSourceCode)
194 {function filterOut(entry)
195 {return entry._projectId===uiSourceCode.project().id()&&entry._path===uiSourceCode.path();}
196 this._historyManager.filterOut(filterOut);},}
197 WebInspector.EditingLocationHistoryEntry=function(sourcesView,editingLocationManager,sourceFrame,selection)
198 {this._sourcesView=sourcesView;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);}
199 WebInspector.EditingLocationHistoryEntry.prototype={merge:function(entry)
200 {if(this._projectId!==entry._projectId||this._path!==entry._path)
201 return;this._positionHandle=entry._positionHandle;},_positionFromSelection:function(selection)
202 {return{lineNumber:selection.endLine,columnNumber:selection.endColumn};},valid:function()
203 {var position=this._positionHandle.resolve();var uiSourceCode=WebInspector.workspace.project(this._projectId).uiSourceCode(this._path);return!!(position&&uiSourceCode);},reveal:function()
204 {var position=this._positionHandle.resolve();var uiSourceCode=WebInspector.workspace.project(this._projectId).uiSourceCode(this._path);if(!position||!uiSourceCode)
205 return;this._editingLocationManager.updateCurrentState();this._sourcesView.showSourceLocation(uiSourceCode,position.lineNumber,position.columnNumber);}};;WebInspector.FilePathScoreFunction=function(query)
206 {this._query=query;this._queryUpperCase=query.toUpperCase();this._score=null;this._sequence=null;this._dataUpperCase="";this._fileNameIndex=0;}
207 WebInspector.FilePathScoreFunction.filterRegex=function(query)
208 {const toEscape=String.regexSpecialCharacters();var regexString="";for(var i=0;i<query.length;++i){var c=query.charAt(i);if(toEscape.indexOf(c)!==-1)
209 c="\\"+c;if(i)
210 regexString+="[^"+c+"]*";regexString+=c;}
211 return new RegExp(regexString,"i");}
212 WebInspector.FilePathScoreFunction.prototype={score:function(data,matchIndexes)
213 {if(!data||!this._query)
214 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);}
215 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;}}}
216 if(matchIndexes)
217 this._restoreMatchIndexes(sequence,n,m,matchIndexes);return score[n*m-1];},_testWordStart:function(data,j)
218 {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)
219 {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;}}
220 out.reverse();},_singleCharScore:function(query,data,i,j)
221 {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)
222 score+=4;if(isWordStart)
223 score+=2;if(isCapsMatch)
224 score+=6;if(isFileName)
225 score+=4;if(j===this._fileNameIndex+1&&i===0)
226 score+=5;if(isFileName&&isWordStart)
227 score+=3;return score;},_sequenceCharScore:function(query,data,i,j,sequenceLength)
228 {var isFileName=j>this._fileNameIndex;var isPathTokenStart=j===0||data[j-1]==="/";var score=10;if(isFileName)
229 score+=4;if(isPathTokenStart)
230 score+=5;score+=sequenceLength*4;return score;},_match:function(query,data,i,j,consecutiveMatch)
231 {if(this._queryUpperCase[i]!==this._dataUpperCase[j])
232 return 0;if(!consecutiveMatch)
233 return this._singleCharScore(query,data,i,j);else
234 return this._sequenceCharScore(query,data,i,j-consecutiveMatch,consecutiveMatch);},};WebInspector.FilteredItemSelectionDialog=function(delegate)
235 {WebInspector.DialogDelegate.call(this);if(!WebInspector.FilteredItemSelectionDialog._stylesLoaded){WebInspector.View.createStyleElement("filteredItemSelectionDialog.css");WebInspector.FilteredItemSelectionDialog._stylesLoaded=true;}
236 this.element=document.createElement("div");this.element.className="filtered-item-list-dialog";this.element.addEventListener("keydown",this._onKeyDown.bind(this),false);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();}
237 WebInspector.FilteredItemSelectionDialog.prototype={position:function(element,relativeToElement)
238 {const shadow=10;const shadowPadding=20;var container=WebInspector.Dialog.modalHostView().element;var preferredWidth=Math.max(relativeToElement.offsetWidth*2/3,500);var width=Math.min(preferredWidth,container.offsetWidth-2*shadowPadding);var preferredHeight=Math.max(relativeToElement.offsetHeight*2/3,204);var height=Math.min(preferredHeight,container.offsetHeight-2*shadowPadding);this.element.style.width=width+"px";var box=relativeToElement.boxInWindow(window).relativeToElement(container);var positionX=box.x+Math.max((box.width-width-2*shadowPadding)/2,shadow);positionX=Math.max(shadow,Math.min(container.offsetWidth-width-2*shadowPadding,positionX));var positionY=box.y+Math.max((box.height-height-2*shadowPadding)/2,shadow);positionY=Math.max(shadow,Math.min(container.offsetHeight-height-2*shadowPadding,positionY));element.positionAt(positionX,positionY,container);this._dialogHeight=height;this._updateShowMatchingItems();},focus:function()
239 {WebInspector.setCurrentFocusElement(this._promptElement);if(this._filteredItems.length&&this._viewportControl.lastVisibleIndex()===-1)
240 this._viewportControl.refresh();},willHide:function()
241 {if(this._isHiding)
242 return;this._isHiding=true;this._delegate.dispose();if(this._filterTimer)
243 clearTimeout(this._filterTimer);},renderAsTwoRows:function()
244 {this._renderAsTwoRows=true;},onEnter:function()
245 {if(!this._delegate.itemCount())
246 return;var selectedIndex=this._selectedIndexInFiltered<this._filteredItems.length?this._filteredItems[this._selectedIndexInFiltered]:null;this._delegate.selectItem(selectedIndex,this._promptElement.value.trim());},_itemsLoaded:function()
247 {if(this._loadTimeout)
248 return;this._loadTimeout=setTimeout(this._updateAfterItemsLoaded.bind(this),0);},_updateAfterItemsLoaded:function()
249 {delete this._loadTimeout;this._filterItems();},_createItemElement:function(index)
250 {var itemElement=document.createElement("div");itemElement.className="filtered-item-list-dialog-item "+(this._renderAsTwoRows?"two-rows":"one-row");itemElement._titleElement=itemElement.createChild("div","filtered-item-list-dialog-title");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)
251 {this._promptElement.value=query;this._scheduleFilter();},_filterItems:function()
252 {delete this._filterTimer;if(this._scoringTimer){clearTimeout(this._scoringTimer);delete this._scoringTimer;}
253 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)
254 {return b-a;}
255 function scoreItems(fromIndex)
256 {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)))
257 continue;var score=this._delegate.itemScoreAt(i,query);if(query)
258 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;}
259 minBestScore=bestScores.peekLast();}else
260 filteredItems.push(i);}
261 if(i<this._delegate.itemCount()){this._scoringTimer=setTimeout(scoreItems.bind(this,i),0);return;}
262 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;}}
263 this._viewportControl.refresh();if(!query)
264 this._selectedIndexInFiltered=0;this._updateSelection(this._selectedIndexInFiltered,false);}},_shouldShowMatchingItems:function()
265 {return this._delegate.shouldShowMatchingItems(this._promptElement.value);},_onInput:function(event)
266 {this._updateShowMatchingItems();this._scheduleFilter();},_updateShowMatchingItems:function()
267 {var shouldShowMatchingItems=this._shouldShowMatchingItems();this._itemElementsContainer.classList.toggle("hidden",!shouldShowMatchingItems);this.element.style.height=shouldShowMatchingItems?this._dialogHeight+"px":"auto";},_onKeyDown:function(event)
268 {var newSelectedIndex=this._selectedIndexInFiltered;switch(event.keyCode){case WebInspector.KeyboardShortcut.Keys.Down.code:if(++newSelectedIndex>=this._filteredItems.length)
269 newSelectedIndex=this._filteredItems.length-1;this._updateSelection(newSelectedIndex,true);event.consume(true);break;case WebInspector.KeyboardShortcut.Keys.Up.code:if(--newSelectedIndex<0)
270 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()
271 {if(this._filterTimer)
272 return;this._filterTimer=setTimeout(this._filterItems.bind(this),0);},_updateSelection:function(index,makeLast)
273 {var element=this._viewportControl.renderedElementAt(this._selectedIndexInFiltered);if(element)
274 element.classList.remove("selected");this._viewportControl.scrollItemIntoView(index,makeLast);this._selectedIndexInFiltered=index;element=this._viewportControl.renderedElementAt(index);if(element)
275 element.classList.add("selected");},_onClick:function(event)
276 {var itemElement=event.target.enclosingNodeOrSelfWithClass("filtered-item-list-dialog-item");if(!itemElement)
277 return;this._delegate.selectItem(itemElement._index,this._promptElement.value.trim());WebInspector.Dialog.hide();},itemCount:function()
278 {return this._filteredItems.length;},itemElement:function(index)
279 {var delegateIndex=this._filteredItems[index];var element=this._createItemElement(delegateIndex);if(index===this._selectedIndexInFiltered)
280 element.classList.add("selected");return element;},__proto__:WebInspector.DialogDelegate.prototype}
281 WebInspector.SelectionDialogContentProvider=function()
282 {}
283 WebInspector.SelectionDialogContentProvider.prototype={setRefreshCallback:function(refreshCallback)
284 {this._refreshCallback=refreshCallback;},shouldShowMatchingItems:function(query)
285 {return true;},itemCount:function()
286 {return 0;},itemKeyAt:function(itemIndex)
287 {return"";},itemScoreAt:function(itemIndex,query)
288 {return 1;},renderItem:function(itemIndex,query,titleElement,subtitleElement)
289 {},highlightRanges:function(element,query)
290 {if(!query)
291 return false;function rangesForMatch(text,query)
292 {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")
293 ranges.push(new WebInspector.SourceRange(opcode[3],opcode[4]-opcode[3]));else if(opcode[0]!=="insert")
294 return null;}
295 return ranges;}
296 var text=element.textContent;var ranges=rangesForMatch(text,query);if(!ranges)
297 ranges=rangesForMatch(text.toUpperCase(),query.toUpperCase());if(ranges){WebInspector.highlightRangesWithStyleClass(element,ranges,"highlight");return true;}
298 return false;},selectItem:function(itemIndex,promptValue)
299 {},refresh:function()
300 {this._refreshCallback();},rewriteQuery:function(query)
301 {return query;},dispose:function()
302 {}}
303 WebInspector.JavaScriptOutlineDialog=function(uiSourceCode,selectItemCallback)
304 {WebInspector.SelectionDialogContentProvider.call(this);this._functionItems=[];this._selectItemCallback=selectItemCallback;this._outlineWorker=new Worker("ScriptFormatterWorker.js");this._outlineWorker.onmessage=this._didBuildOutlineChunk.bind(this);this._outlineWorker.postMessage({method:"javaScriptOutline",params:{content:uiSourceCode.workingCopy()}});}
305 WebInspector.JavaScriptOutlineDialog.show=function(view,uiSourceCode,selectItemCallback)
306 {if(WebInspector.Dialog.currentInstance())
307 return null;var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(new WebInspector.JavaScriptOutlineDialog(uiSourceCode,selectItemCallback));WebInspector.Dialog.show(view.element,filteredItemSelectionDialog);}
308 WebInspector.JavaScriptOutlineDialog.prototype={_didBuildOutlineChunk:function(event)
309 {var data=(event.data);var chunk=data.chunk;for(var i=0;i<chunk.length;++i)
310 this._functionItems.push(chunk[i]);if(data.total===data.index+1)
311 this.dispose();this.refresh();},itemCount:function()
312 {return this._functionItems.length;},itemKeyAt:function(itemIndex)
313 {return this._functionItems[itemIndex].name;},itemScoreAt:function(itemIndex,query)
314 {var item=this._functionItems[itemIndex];return-item.line;},renderItem:function(itemIndex,query,titleElement,subtitleElement)
315 {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)
316 {if(itemIndex===null)
317 return;var lineNumber=this._functionItems[itemIndex].line;if(!isNaN(lineNumber)&&lineNumber>=0)
318 this._selectItemCallback(lineNumber,this._functionItems[itemIndex].column);},dispose:function()
319 {if(this._outlineWorker){this._outlineWorker.terminate();delete this._outlineWorker;}},__proto__:WebInspector.SelectionDialogContentProvider.prototype}
320 WebInspector.SelectUISourceCodeDialog=function(defaultScores)
321 {WebInspector.SelectionDialogContentProvider.call(this);this._uiSourceCodes=[];var projects=WebInspector.workspace.projects().filter(this.filterProject.bind(this));for(var i=0;i<projects.length;++i)
322 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);}
323 WebInspector.SelectUISourceCodeDialog.prototype={uiSourceCodeSelected:function(uiSourceCode,lineNumber,columnNumber)
324 {},filterProject:function(project)
325 {return true;},itemCount:function()
326 {return this._uiSourceCodes.length;},itemKeyAt:function(itemIndex)
327 {return this._uiSourceCodes[itemIndex].fullDisplayName();},itemScoreAt:function(itemIndex,query)
328 {var uiSourceCode=this._uiSourceCodes[itemIndex];var score=this._defaultScores?(this._defaultScores.get(uiSourceCode)||0):0;if(!query||query.length<2)
329 return score;if(this._query!==query){this._query=query;this._scorer=new WebInspector.FilePathScoreFunction(query);}
330 var path=uiSourceCode.fullDisplayName();return score+10*this._scorer.score(path,null);},renderItem:function(itemIndex,query,titleElement,subtitleElement)
331 {query=this.rewriteQuery(query);var uiSourceCode=this._uiSourceCodes[itemIndex];titleElement.textContent=uiSourceCode.displayName()+(this._queryLineNumberAndColumnNumber||"");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)
332 ranges.push({offset:indexes[i],length:1});if(indexes[0]>fileNameIndex){for(var i=0;i<ranges.length;++i)
333 ranges[i].offset-=fileNameIndex+1;return WebInspector.highlightRangesWithStyleClass(titleElement,ranges,"highlight");}else{return WebInspector.highlightRangesWithStyleClass(subtitleElement,ranges,"highlight");}},selectItem:function(itemIndex,promptValue)
334 {var parsedExpression=promptValue.trim().match(/^([^:]*)(:\d+)?(:\d+)?$/);if(!parsedExpression)
335 return;var lineNumber;var columnNumber;if(parsedExpression[2])
336 lineNumber=parseInt(parsedExpression[2].substr(1),10)-1;if(parsedExpression[3])
337 columnNumber=parseInt(parsedExpression[3].substr(1),10)-1;var uiSourceCode=itemIndex!==null?this._uiSourceCodes[itemIndex]:null;this.uiSourceCodeSelected(uiSourceCode,lineNumber,columnNumber);},rewriteQuery:function(query)
338 {if(!query)
339 return query;query=query.trim();var lineNumberMatch=query.match(/^([^:]+)((?::[^:]*){0,2})$/);this._queryLineNumberAndColumnNumber=lineNumberMatch?lineNumberMatch[2]:"";return lineNumberMatch?lineNumberMatch[1]:query;},_uiSourceCodeAdded:function(event)
340 {var uiSourceCode=(event.data);if(!this.filterProject(uiSourceCode.project()))
341 return;this._uiSourceCodes.push(uiSourceCode)
342 this.refresh();},dispose:function()
343 {WebInspector.workspace.removeEventListener(WebInspector.Workspace.Events.UISourceCodeAdded,this._uiSourceCodeAdded,this);},__proto__:WebInspector.SelectionDialogContentProvider.prototype}
344 WebInspector.OpenResourceDialog=function(sourcesView,defaultScores)
345 {WebInspector.SelectUISourceCodeDialog.call(this,defaultScores);this._sourcesView=sourcesView;}
346 WebInspector.OpenResourceDialog.prototype={uiSourceCodeSelected:function(uiSourceCode,lineNumber,columnNumber)
347 {if(!uiSourceCode)
348 uiSourceCode=this._sourcesView.currentUISourceCode();if(!uiSourceCode)
349 return;this._sourcesView.showSourceLocation(uiSourceCode,lineNumber,columnNumber);},shouldShowMatchingItems:function(query)
350 {return!query.startsWith(":");},filterProject:function(project)
351 {return!project.isServiceProject();},__proto__:WebInspector.SelectUISourceCodeDialog.prototype}
352 WebInspector.OpenResourceDialog.show=function(sourcesView,relativeToElement,query,defaultScores)
353 {if(WebInspector.Dialog.currentInstance())
354 return;var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(sourcesView,defaultScores));filteredItemSelectionDialog.renderAsTwoRows();if(query)
355 filteredItemSelectionDialog.setQuery(query);WebInspector.Dialog.show(relativeToElement,filteredItemSelectionDialog);}
356 WebInspector.SelectUISourceCodeForProjectTypeDialog=function(type,callback)
357 {this._type=type;WebInspector.SelectUISourceCodeDialog.call(this);this._callback=callback;}
358 WebInspector.SelectUISourceCodeForProjectTypeDialog.prototype={uiSourceCodeSelected:function(uiSourceCode,lineNumber,columnNumber)
359 {this._callback(uiSourceCode);},filterProject:function(project)
360 {return project.type()===this._type;},__proto__:WebInspector.SelectUISourceCodeDialog.prototype}
361 WebInspector.SelectUISourceCodeForProjectTypeDialog.show=function(name,type,callback,relativeToElement)
362 {if(WebInspector.Dialog.currentInstance())
363 return;var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type,callback));filteredItemSelectionDialog.setQuery(name);filteredItemSelectionDialog.renderAsTwoRows();WebInspector.Dialog.show(relativeToElement,filteredItemSelectionDialog);}
364 WebInspector.JavaScriptOutlineDialog.MessageEventData;;WebInspector.UISourceCodeFrame=function(uiSourceCode)
365 {this._uiSourceCode=uiSourceCode;WebInspector.SourceFrame.call(this,this._uiSourceCode);WebInspector.settings.textEditorAutocompletion.addChangeListener(this._enableAutocompletionIfNeeded,this);this._enableAutocompletionIfNeeded();this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged,this._onWorkingCopyChanged,this);this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted,this._onWorkingCopyCommitted,this);this._updateStyle();}
366 WebInspector.UISourceCodeFrame.prototype={uiSourceCode:function()
367 {return this._uiSourceCode;},_enableAutocompletionIfNeeded:function()
368 {this.textEditor.setCompletionDictionary(WebInspector.settings.textEditorAutocompletion.get()?new WebInspector.SampleCompletionDictionary():null);},wasShown:function()
369 {WebInspector.SourceFrame.prototype.wasShown.call(this);this._boundWindowFocused=this._windowFocused.bind(this);window.addEventListener("focus",this._boundWindowFocused,false);this._checkContentUpdated();},willHide:function()
370 {WebInspector.SourceFrame.prototype.willHide.call(this);window.removeEventListener("focus",this._boundWindowFocused,false);delete this._boundWindowFocused;this._uiSourceCode.removeWorkingCopyGetter();},canEditSource:function()
371 {return this._uiSourceCode.isEditable();},_windowFocused:function(event)
372 {this._checkContentUpdated();},_checkContentUpdated:function()
373 {if(!this.loaded||!this.isShowing())
374 return;this._uiSourceCode.checkContentUpdated();},commitEditing:function()
375 {if(!this._uiSourceCode.isDirty())
376 return;this._muteSourceCodeEvents=true;this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));delete this._muteSourceCodeEvents;},onTextChanged:function(oldRange,newRange)
377 {WebInspector.SourceFrame.prototype.onTextChanged.call(this,oldRange,newRange);if(this._isSettingContent)
378 return;this._muteSourceCodeEvents=true;if(this._textEditor.isClean())
379 this._uiSourceCode.resetWorkingCopy();else
380 this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(this._textEditor));delete this._muteSourceCodeEvents;},_didEditContent:function(error)
381 {if(error){WebInspector.console.log(error,WebInspector.ConsoleMessage.MessageLevel.Error,true);return;}},_onWorkingCopyChanged:function(event)
382 {if(this._muteSourceCodeEvents)
383 return;this._innerSetContent(this._uiSourceCode.workingCopy());this.onUISourceCodeContentChanged();},_onWorkingCopyCommitted:function(event)
384 {if(!this._muteSourceCodeEvents){this._innerSetContent(this._uiSourceCode.workingCopy());this.onUISourceCodeContentChanged();}
385 this._textEditor.markClean();this._updateStyle();},_updateStyle:function()
386 {this.element.classList.toggle("source-frame-unsaved-committed-changes",this._uiSourceCode.hasUnsavedCommittedChanges());},onUISourceCodeContentChanged:function()
387 {},_innerSetContent:function(content)
388 {this._isSettingContent=true;this.setContent(content);delete this._isSettingContent;},populateTextAreaContextMenu:function(contextMenu,lineNumber)
389 {WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this,contextMenu,lineNumber);contextMenu.appendApplicableItems(this._uiSourceCode);contextMenu.appendSeparator();},dispose:function()
390 {this.detach();},__proto__:WebInspector.SourceFrame.prototype};WebInspector.JavaScriptSourceFrame=function(scriptsPanel,uiSourceCode)
391 {this._scriptsPanel=scriptsPanel;this._breakpointManager=WebInspector.breakpointManager;this._uiSourceCode=uiSourceCode;WebInspector.UISourceCodeFrame.call(this,uiSourceCode);if(uiSourceCode.project().type()===WebInspector.projectTypes.Debugger)
392 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._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();}
393 WebInspector.JavaScriptSourceFrame.prototype={_registerShortcuts:function()
394 {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));}
395 for(var i=0;i<shortcutKeys.AddSelectionToWatch.length;++i){var keyDescriptor=shortcutKeys.AddSelectionToWatch[i];this.addShortcut(keyDescriptor.key,this._addCurrentSelectionToWatch.bind(this));}},_addCurrentSelectionToWatch:function()
396 {var textSelection=this.textEditor.selection();if(textSelection&&!textSelection.isEmpty())
397 this._innerAddToWatch(this.textEditor.copyRange(textSelection));},_innerAddToWatch:function(expression)
398 {this._scriptsPanel.addToWatch(expression);},_evaluateSelectionInConsole:function()
399 {var selection=this.textEditor.selection();if(!selection||selection.isEmpty())
400 return false;this._evaluateInConsole(this.textEditor.copyRange(selection));return true;},_evaluateInConsole:function(expression)
401 {WebInspector.console.evaluate(expression);},wasShown:function()
402 {WebInspector.UISourceCodeFrame.prototype.wasShown.call(this);},willHide:function()
403 {WebInspector.UISourceCodeFrame.prototype.willHide.call(this);this._popoverHelper.hidePopover();},onUISourceCodeContentChanged:function()
404 {this._removeAllBreakpoints();WebInspector.UISourceCodeFrame.prototype.onUISourceCodeContentChanged.call(this);},populateLineGutterContextMenu:function(contextMenu,lineNumber)
405 {contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Continue to here":"Continue to Here"),this._continueToLine.bind(this,lineNumber));var breakpoint=this._breakpointManager.findBreakpointOnLine(this._uiSourceCode,lineNumber);if(!breakpoint){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add breakpoint":"Add Breakpoint"),this._setBreakpoint.bind(this,lineNumber,0,"",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())
406 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Disable breakpoint":"Disable Breakpoint"),breakpoint.setEnabled.bind(breakpoint,false));else
407 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Enable breakpoint":"Enable Breakpoint"),breakpoint.setEnabled.bind(breakpoint,true));}},populateTextAreaContextMenu:function(contextMenu,lineNumber)
408 {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,this._evaluateInConsole.bind(this,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();}
409 function liveEdit()
410 {var liveEditUISourceCode=WebInspector.liveEditSupport.uiSourceCodeForLiveEdit(this._uiSourceCode);this._scriptsPanel.showUISourceCode(liveEditUISourceCode,lineNumber)}
411 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.call(this,contextMenu,lineNumber);},_workingCopyChanged:function(event)
412 {if(this._supportsEnabledBreakpointsWhileEditing()||this._scriptFile)
413 return;if(this._uiSourceCode.isDirty())
414 this._muteBreakpointsWhileEditing();else
415 this._restoreBreakpointsAfterEditing();},_workingCopyCommitted:function(event)
416 {if(this._supportsEnabledBreakpointsWhileEditing()||this._scriptFile)
417 return;this._restoreBreakpointsAfterEditing();},_didMergeToVM:function()
418 {if(this._supportsEnabledBreakpointsWhileEditing())
419 return;this._restoreBreakpointsAfterEditing();},_didDivergeFromVM:function()
420 {if(this._supportsEnabledBreakpointsWhileEditing())
421 return;this._muteBreakpointsWhileEditing();},_muteBreakpointsWhileEditing:function()
422 {if(this._muted)
423 return;for(var lineNumber=0;lineNumber<this._textEditor.linesCount;++lineNumber){var breakpointDecoration=this._textEditor.getAttribute(lineNumber,"breakpoint");if(!breakpointDecoration)
424 continue;this._removeBreakpointDecoration(lineNumber);this._addBreakpointDecoration(lineNumber,breakpointDecoration.columnNumber,breakpointDecoration.condition,breakpointDecoration.enabled,true);}
425 this._muted=true;},_supportsEnabledBreakpointsWhileEditing:function()
426 {return this._uiSourceCode.project().type()===WebInspector.projectTypes.Snippets;},_restoreBreakpointsAfterEditing:function()
427 {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);}}
428 this._removeAllBreakpoints();for(var lineNumberString in breakpoints){var lineNumber=parseInt(lineNumberString,10);if(isNaN(lineNumber))
429 continue;var breakpointDecoration=breakpoints[lineNumberString];this._setBreakpoint(lineNumber,breakpointDecoration.columnNumber,breakpointDecoration.condition,breakpointDecoration.enabled);}},_removeAllBreakpoints:function()
430 {var breakpoints=this._breakpointManager.breakpointsForUISourceCode(this._uiSourceCode);for(var i=0;i<breakpoints.length;++i)
431 breakpoints[i].remove();},_getPopoverAnchor:function(element,event)
432 {if(!WebInspector.debuggerModel.isPaused())
433 return null;var textPosition=this.textEditor.coordinatesToCursorPosition(event.x,event.y);if(!textPosition)
434 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)
435 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;}
436 var token=this.textEditor.tokenAtTextPosition(textPosition.startLine,textPosition.startColumn);if(!token)
437 return null;var lineNumber=textPosition.startLine;var line=this.textEditor.line(lineNumber);var tokenContent=line.substring(token.startColumn,token.endColumn+1);var isIdentifier=token.type.startsWith("js-variable")||token.type.startsWith("js-property")||token.type=="js-def";if(!isIdentifier&&(token.type!=="js-keyword"||tokenContent!=="this"))
438 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)
439 {function showObjectPopover(result,wasThrown)
440 {if(!WebInspector.debuggerModel.isPaused()||!result){this._popoverHelper.hidePopover();return;}
441 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");}}
442 if(!WebInspector.debuggerModel.isPaused()){this._popoverHelper.hidePopover();return;}
443 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;}
444 startHighlight=token.startColumn;}}
445 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()
446 {if(!this._popoverAnchorBox)
447 return;if(this._popoverAnchorBox._highlightDescriptor)
448 this.textEditor.removeHighlight(this._popoverAnchorBox._highlightDescriptor);delete this._popoverAnchorBox;},_addBreakpointDecoration:function(lineNumber,columnNumber,condition,enabled,mutedWhileEditing)
449 {var breakpoint={condition:condition,enabled:enabled,columnNumber:columnNumber};this.textEditor.setAttribute(lineNumber,"breakpoint",breakpoint);var disabled=!enabled||mutedWhileEditing;this.textEditor.addBreakpoint(lineNumber,disabled,!!condition);},_removeBreakpointDecoration:function(lineNumber)
450 {this.textEditor.removeAttribute(lineNumber,"breakpoint");this.textEditor.removeBreakpoint(lineNumber);},_onKeyDown:function(event)
451 {if(event.keyIdentifier==="U+001B"){if(this._popoverHelper.isPopoverVisible()){this._popoverHelper.hidePopover();event.consume();}}},_editBreakpointCondition:function(lineNumber,breakpoint)
452 {this._conditionElement=this._createConditionElement(lineNumber);this.textEditor.addDecoration(lineNumber,this._conditionElement);function finishEditing(committed,element,newText)
453 {this.textEditor.removeDecoration(lineNumber,this._conditionElement);delete this._conditionEditorElement;delete this._conditionElement;if(!committed)
454 return;if(breakpoint)
455 breakpoint.setCondition(newText);else
456 this._setBreakpoint(lineNumber,0,newText,true);}
457 var config=new WebInspector.InplaceEditor.Config(finishEditing.bind(this,true),finishEditing.bind(this,false));WebInspector.InplaceEditor.startEditing(this._conditionEditorElement,config);this._conditionEditorElement.value=breakpoint?breakpoint.condition():"";this._conditionEditorElement.select();},_createConditionElement:function(lineNumber)
458 {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)
459 {this._executionLineNumber=lineNumber;if(this.loaded)
460 this.textEditor.setExecutionLine(lineNumber);},clearExecutionLine:function()
461 {if(this.loaded&&typeof this._executionLineNumber==="number")
462 this.textEditor.clearExecutionLine();delete this._executionLineNumber;},_shouldIgnoreExternalBreakpointEvents:function()
463 {if(this._supportsEnabledBreakpointsWhileEditing())
464 return false;if(this._muted)
465 return true;return this._scriptFile&&(this._scriptFile.isDivergingFromVM()||this._scriptFile.isMergingToVM());},_breakpointAdded:function(event)
466 {var uiLocation=(event.data.uiLocation);if(uiLocation.uiSourceCode!==this._uiSourceCode)
467 return;if(this._shouldIgnoreExternalBreakpointEvents())
468 return;var breakpoint=(event.data.breakpoint);if(this.loaded)
469 this._addBreakpointDecoration(uiLocation.lineNumber,uiLocation.columnNumber,breakpoint.condition(),breakpoint.enabled(),false);},_breakpointRemoved:function(event)
470 {var uiLocation=(event.data.uiLocation);if(uiLocation.uiSourceCode!==this._uiSourceCode)
471 return;if(this._shouldIgnoreExternalBreakpointEvents())
472 return;var breakpoint=(event.data.breakpoint);var remainingBreakpoint=this._breakpointManager.findBreakpointOnLine(this._uiSourceCode,uiLocation.lineNumber);if(!remainingBreakpoint&&this.loaded)
473 this._removeBreakpointDecoration(uiLocation.lineNumber);},_consoleMessageAdded:function(event)
474 {var message=(event.data);if(this.loaded)
475 this.addMessageToSource(message.lineNumber,message.originalMessage);},_consoleMessageRemoved:function(event)
476 {var message=(event.data);if(this.loaded)
477 this.removeMessageFromSource(message.lineNumber,message.originalMessage);},_consoleMessagesCleared:function(event)
478 {this.clearMessages();},_onSourceMappingChanged:function(event)
479 {this._updateScriptFile();},_updateScriptFile:function()
480 {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())
481 this._restoreBreakpointsAfterEditing();}
482 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)
483 this._scriptFile.checkMapping();}},onTextEditorContentLoaded:function()
484 {if(typeof this._executionLineNumber==="number")
485 this.setExecutionLine(this._executionLineNumber);var breakpointLocations=this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);for(var i=0;i<breakpointLocations.length;++i)
486 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);}
487 if(this._scriptFile)
488 this._scriptFile.checkMapping();},_handleGutterClick:function(event)
489 {if(this._muted)
490 return;var eventData=(event.data);var lineNumber=eventData.lineNumber;var eventObject=(eventData.event);if(eventObject.button!=0||eventObject.altKey||eventObject.ctrlKey||eventObject.metaKey)
491 return;this._toggleBreakpoint(lineNumber,eventObject.shiftKey);eventObject.consume(true);},_toggleBreakpoint:function(lineNumber,onlyDisable)
492 {var breakpoint=this._breakpointManager.findBreakpointOnLine(this._uiSourceCode,lineNumber);if(breakpoint){if(onlyDisable)
493 breakpoint.setEnabled(!breakpoint.enabled());else
494 breakpoint.remove();}else
495 this._setBreakpoint(lineNumber,0,"",true);},toggleBreakpointOnCurrentLine:function()
496 {if(this._muted)
497 return;var selection=this.textEditor.selection();if(!selection)
498 return;this._toggleBreakpoint(selection.startLine,false);},_setBreakpoint:function(lineNumber,columnNumber,condition,enabled)
499 {this._breakpointManager.setBreakpoint(this._uiSourceCode,lineNumber,columnNumber,condition,enabled);WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.SetBreakpoint,url:this._uiSourceCode.originURL(),line:lineNumber,enabled:enabled});},_continueToLine:function(lineNumber)
500 {var rawLocation=(this._uiSourceCode.uiLocationToRawLocation(lineNumber,0));this._scriptsPanel.continueToLocation(rawLocation);},dispose:function()
501 {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};WebInspector.CSSSourceFrame=function(uiSourceCode)
502 {WebInspector.UISourceCodeFrame.call(this,uiSourceCode);this._registerShortcuts();}
503 WebInspector.CSSSourceFrame.prototype={_registerShortcuts:function()
504 {var shortcutKeys=WebInspector.ShortcutsScreen.SourcesPanelShortcuts;for(var i=0;i<shortcutKeys.IncreaseCSSUnitByOne.length;++i)
505 this.addShortcut(shortcutKeys.IncreaseCSSUnitByOne[i].key,this._handleUnitModification.bind(this,1));for(var i=0;i<shortcutKeys.DecreaseCSSUnitByOne.length;++i)
506 this.addShortcut(shortcutKeys.DecreaseCSSUnitByOne[i].key,this._handleUnitModification.bind(this,-1));for(var i=0;i<shortcutKeys.IncreaseCSSUnitByTen.length;++i)
507 this.addShortcut(shortcutKeys.IncreaseCSSUnitByTen[i].key,this._handleUnitModification.bind(this,10));for(var i=0;i<shortcutKeys.DecreaseCSSUnitByTen.length;++i)
508 this.addShortcut(shortcutKeys.DecreaseCSSUnitByTen[i].key,this._handleUnitModification.bind(this,-10));},_modifyUnit:function(unit,change)
509 {var unitValue=parseInt(unit,10);if(isNaN(unitValue))
510 return null;var tail=unit.substring((unitValue).toString().length);return String.sprintf("%d%s",unitValue+change,tail);},_handleUnitModification:function(change)
511 {var selection=this.textEditor.selection().normalize();var token=this.textEditor.tokenAtTextPosition(selection.startLine,selection.startColumn);if(!token){if(selection.startColumn>0)
512 token=this.textEditor.tokenAtTextPosition(selection.startLine,selection.startColumn-1);if(!token)
513 return false;}
514 if(token.type!=="css-number")
515 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)
516 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.NavigatorView=function()
517 {WebInspector.VBox.call(this);this.registerRequiredCSS("navigatorView.css");var scriptsTreeElement=document.createElement("ol");this._scriptsTree=new WebInspector.NavigatorTreeOutline(scriptsTreeElement);var scriptsOutlineElement=document.createElement("div");scriptsOutlineElement.classList.add("outline-disclosure");scriptsOutlineElement.classList.add("navigator");scriptsOutlineElement.appendChild(scriptsTreeElement);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();this.element.addEventListener("contextmenu",this.handleContextMenu.bind(this),false);}
518 WebInspector.NavigatorView.Events={ItemSelected:"ItemSelected",ItemRenamed:"ItemRenamed",}
519 WebInspector.NavigatorView.iconClassForType=function(type)
520 {if(type===WebInspector.NavigatorTreeOutline.Types.Domain)
521 return"navigator-domain-tree-item";if(type===WebInspector.NavigatorTreeOutline.Types.FileSystem)
522 return"navigator-folder-tree-item";return"navigator-folder-tree-item";}
523 WebInspector.NavigatorView.prototype={setWorkspace:function(workspace)
524 {this._workspace=workspace;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);},wasShown:function()
525 {if(this._loaded)
526 return;this._loaded=true;this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));},accept:function(uiSourceCode)
527 {return!uiSourceCode.project().isServiceProject();},_addUISourceCode:function(uiSourceCode)
528 {if(!this.accept(uiSourceCode))
529 return;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);},_uiSourceCodeAdded:function(event)
530 {var uiSourceCode=(event.data);this._addUISourceCode(uiSourceCode);},_uiSourceCodeRemoved:function(event)
531 {var uiSourceCode=(event.data);this._removeUISourceCode(uiSourceCode);},_projectWillReset:function(event)
532 {var project=(event.data);var uiSourceCodes=project.uiSourceCodes();for(var i=0;i<uiSourceCodes.length;++i)
533 this._removeUISourceCode(uiSourceCodes[i]);},_projectNode:function(project)
534 {if(!project.displayName())
535 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);}
536 return projectNode;},_folderNode:function(projectNode,folderPath)
537 {if(!folderPath)
538 return projectNode;var subfolderNodes=this._subfolderNodes.get(projectNode);if(!subfolderNodes){subfolderNodes=(new StringMap());this._subfolderNodes.put(projectNode,subfolderNodes);}
539 var folderNode=subfolderNodes.get(folderPath);if(folderNode)
540 return folderNode;var parentNode=projectNode;var index=folderPath.lastIndexOf("/");if(index!==-1)
541 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)
542 {var node=this._uiSourceCodeNodes.get(uiSourceCode);if(!node)
543 return;if(this._scriptsTree.selectedTreeElement)
544 this._scriptsTree.selectedTreeElement.deselect();this._lastSelectedUISourceCode=uiSourceCode;node.reveal(select);},_sourceSelected:function(uiSourceCode,focusSource)
545 {this._lastSelectedUISourceCode=uiSourceCode;var data={uiSourceCode:uiSourceCode,focusSource:focusSource};this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemSelected,data);},sourceDeleted:function(uiSourceCode)
546 {},_removeUISourceCode:function(uiSourceCode)
547 {var node=this._uiSourceCodeNodes.get(uiSourceCode);if(!node)
548 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())
549 break;if(subfolderNodes)
550 subfolderNodes.remove(node._folderPath);parentNode.removeChild(node);node=parentNode;}},_updateIcon:function(uiSourceCode)
551 {var node=this._uiSourceCodeNodes.get(uiSourceCode);node.updateIcon();},reset:function()
552 {var nodes=this._uiSourceCodeNodes.values();for(var i=0;i<nodes.length;++i)
553 nodes[i].dispose();this._scriptsTree.removeChildren();this._uiSourceCodeNodes.clear();this._subfolderNodes.clear();this._rootNode.reset();},handleContextMenu:function(event)
554 {var contextMenu=new WebInspector.ContextMenu(event);this._appendAddFolderItem(contextMenu);contextMenu.show();},_appendAddFolderItem:function(contextMenu)
555 {function addFolder()
556 {WebInspector.isolatedFileSystemManager.addFileSystem();}
557 var addFolderLabel=WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Add folder to workspace":"Add Folder to Workspace");contextMenu.appendItem(addFolderLabel,addFolder);},_handleContextMenuRefresh:function(project,path)
558 {project.refresh(path);},_handleContextMenuCreate:function(project,path,uiSourceCode)
559 {this.create(project,path,uiSourceCode);},_handleContextMenuExclude:function(project,path)
560 {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)
561 {var shouldDelete=window.confirm(WebInspector.UIString("Are you sure you want to delete this file?"));if(shouldDelete)
562 uiSourceCode.project().deleteFile(uiSourceCode.path());},handleFileContextMenu:function(event,uiSourceCode)
563 {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)
564 {var contextMenu=new WebInspector.ContextMenu(event);var path="/";var projectNode=node;while(projectNode.parent!==this._rootNode){path="/"+projectNode.id+path;projectNode=projectNode.parent;}
565 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));}
566 contextMenu.appendSeparator();this._appendAddFolderItem(contextMenu);function removeFolder()
567 {var shouldRemove=window.confirm(WebInspector.UIString("Are you sure you want to remove this folder?"));if(shouldRemove)
568 project.remove();}
569 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);}
570 contextMenu.show();},rename:function(uiSourceCode,deleteIfCanceled)
571 {var node=this._uiSourceCodeNodes.get(uiSourceCode);console.assert(node);node.rename(callback.bind(this));function callback(committed)
572 {if(!committed){if(deleteIfCanceled)
573 uiSourceCode.remove();return;}
574 var data={uiSourceCode:uiSourceCode};this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemRenamed,data);this._updateIcon(uiSourceCode);this._sourceSelected(uiSourceCode,true)}},create:function(project,path,uiSourceCodeToCopy)
575 {var filePath;var uiSourceCode;function contentLoaded(content)
576 {createFile.call(this,content||"");}
577 if(uiSourceCodeToCopy)
578 uiSourceCodeToCopy.requestContent(contentLoaded.bind(this));else
579 createFile.call(this);function createFile(content)
580 {project.createFile(path,null,content||"",fileCreated.bind(this));}
581 function fileCreated(path)
582 {if(!path)
583 return;filePath=path;uiSourceCode=project.uiSourceCode(filePath);if(!uiSourceCode){console.assert(uiSourceCode)
584 return;}
585 this._sourceSelected(uiSourceCode,false);this.rename(uiSourceCode,true);}},__proto__:WebInspector.VBox.prototype}
586 WebInspector.SourcesNavigatorView=function()
587 {WebInspector.NavigatorView.call(this);WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged,this._inspectedURLChanged,this);}
588 WebInspector.SourcesNavigatorView.prototype={accept:function(uiSourceCode)
589 {if(!WebInspector.NavigatorView.prototype.accept(uiSourceCode))
590 return false;return!uiSourceCode.isContentScript&&uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets;},_inspectedURLChanged:function(event)
591 {var nodes=this._uiSourceCodeNodes.values();for(var i=0;i<nodes.length;++i){var uiSourceCode=nodes[i].uiSourceCode();if(uiSourceCode.url===WebInspector.resourceTreeModel.inspectedPageURL())
592 this.revealUISourceCode(uiSourceCode,true);}},_addUISourceCode:function(uiSourceCode)
593 {WebInspector.NavigatorView.prototype._addUISourceCode.call(this,uiSourceCode);if(uiSourceCode.url===WebInspector.resourceTreeModel.inspectedPageURL())
594 this.revealUISourceCode(uiSourceCode,true);},__proto__:WebInspector.NavigatorView.prototype}
595 WebInspector.ContentScriptsNavigatorView=function()
596 {WebInspector.NavigatorView.call(this);}
597 WebInspector.ContentScriptsNavigatorView.prototype={accept:function(uiSourceCode)
598 {if(!WebInspector.NavigatorView.prototype.accept(uiSourceCode))
599 return false;return uiSourceCode.isContentScript;},__proto__:WebInspector.NavigatorView.prototype}
600 WebInspector.NavigatorTreeOutline=function(element)
601 {TreeOutline.call(this,element);this.element=element;this.comparator=WebInspector.NavigatorTreeOutline._treeElementsCompare;}
602 WebInspector.NavigatorTreeOutline.Types={Root:"Root",Domain:"Domain",Folder:"Folder",UISourceCode:"UISourceCode",FileSystem:"FileSystem"}
603 WebInspector.NavigatorTreeOutline._treeElementsCompare=function compare(treeElement1,treeElement2)
604 {function typeWeight(treeElement)
605 {var type=treeElement.type();if(type===WebInspector.NavigatorTreeOutline.Types.Domain){if(treeElement.titleText===WebInspector.resourceTreeModel.inspectedPageDomain())
606 return 1;return 2;}
607 if(type===WebInspector.NavigatorTreeOutline.Types.FileSystem)
608 return 3;if(type===WebInspector.NavigatorTreeOutline.Types.Folder)
609 return 4;return 5;}
610 var typeWeight1=typeWeight(treeElement1);var typeWeight2=typeWeight(treeElement2);var result;if(typeWeight1>typeWeight2)
611 result=1;else if(typeWeight1<typeWeight2)
612 result=-1;else{var title1=treeElement1.titleText;var title2=treeElement2.titleText;result=title1.compareTo(title2);}
613 return result;}
614 WebInspector.NavigatorTreeOutline.prototype={scriptTreeElements:function()
615 {var result=[];if(this.children.length){for(var treeElement=this.children[0];treeElement;treeElement=treeElement.traverseNextTreeElement(false,this,true)){if(treeElement instanceof WebInspector.NavigatorSourceTreeElement)
616 result.push(treeElement.uiSourceCode);}}
617 return result;},__proto__:TreeOutline.prototype}
618 WebInspector.BaseNavigatorTreeElement=function(type,title,iconClasses,hasChildren,noIcon)
619 {this._type=type;TreeElement.call(this,"",null,hasChildren);this._titleText=title;this._iconClasses=iconClasses;this._noIcon=noIcon;}
620 WebInspector.BaseNavigatorTreeElement.prototype={onattach:function()
621 {this.listItemElement.removeChildren();if(this._iconClasses){for(var i=0;i<this._iconClasses.length;++i)
622 this.listItemElement.classList.add(this._iconClasses[i]);}
623 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);}
624 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)
625 {for(var i=0;i<this._iconClasses.length;++i)
626 this.listItemElement.classList.remove(this._iconClasses[i]);this._iconClasses=iconClasses;for(var i=0;i<this._iconClasses.length;++i)
627 this.listItemElement.classList.add(this._iconClasses[i]);},onreveal:function()
628 {if(this.listItemElement)
629 this.listItemElement.scrollIntoViewIfNeeded(true);},get titleText()
630 {return this._titleText;},set titleText(titleText)
631 {if(this._titleText===titleText)
632 return;this._titleText=titleText||"";if(this.titleElement)
633 this.titleElement.textContent=this._titleText;},type:function()
634 {return this._type;},__proto__:TreeElement.prototype}
635 WebInspector.NavigatorFolderTreeElement=function(navigatorView,type,title)
636 {var iconClass=WebInspector.NavigatorView.iconClassForType(type);WebInspector.BaseNavigatorTreeElement.call(this,type,title,[iconClass],true);this._navigatorView=navigatorView;}
637 WebInspector.NavigatorFolderTreeElement.prototype={onpopulate:function()
638 {this._node.populate();},onattach:function()
639 {WebInspector.BaseNavigatorTreeElement.prototype.onattach.call(this);this.collapse();this.listItemElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),false);},setNode:function(node)
640 {this._node=node;var paths=[];while(node&&!node.isRoot()){paths.push(node._title);node=node.parent;}
641 paths.reverse();this.tooltip=paths.join("/");},_handleContextMenuEvent:function(event)
642 {if(!this._node)
643 return;this.select();this._navigatorView.handleFolderContextMenu((event),this._node);},__proto__:WebInspector.BaseNavigatorTreeElement.prototype}
644 WebInspector.NavigatorSourceTreeElement=function(navigatorView,uiSourceCode,title)
645 {this._navigatorView=navigatorView;this._uiSourceCode=uiSourceCode;WebInspector.BaseNavigatorTreeElement.call(this,WebInspector.NavigatorTreeOutline.Types.UISourceCode,title,this._calculateIconClasses(),false);this.tooltip=uiSourceCode.originURL();}
646 WebInspector.NavigatorSourceTreeElement.prototype={get uiSourceCode()
647 {return this._uiSourceCode;},_calculateIconClasses:function()
648 {return["navigator-"+this._uiSourceCode.contentType().name()+"-tree-item"];},updateIcon:function()
649 {this.updateIconClasses(this._calculateIconClasses());},onattach:function()
650 {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)
651 {if(event.which===1)
652 this._uiSourceCode.requestContent(callback.bind(this));function callback(content)
653 {this._warmedUpContent=content;}},_shouldRenameOnMouseDown:function()
654 {if(!this._uiSourceCode.canRename())
655 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)
656 {if(event.which!==1||!this._shouldRenameOnMouseDown()){TreeElement.prototype.selectOnMouseDown.call(this,event);return;}
657 setTimeout(rename.bind(this),300);function rename()
658 {if(this._shouldRenameOnMouseDown())
659 this._navigatorView.rename(this.uiSourceCode,false);}},_ondragstart:function(event)
660 {event.dataTransfer.setData("text/plain",this._warmedUpContent);event.dataTransfer.effectAllowed="copy";return true;},onspace:function()
661 {this._navigatorView._sourceSelected(this.uiSourceCode,true);return true;},_onclick:function(event)
662 {this._navigatorView._sourceSelected(this.uiSourceCode,false);},ondblclick:function(event)
663 {var middleClick=event.button===1;this._navigatorView._sourceSelected(this.uiSourceCode,!middleClick);return false;},onenter:function()
664 {this._navigatorView._sourceSelected(this.uiSourceCode,true);return true;},ondelete:function()
665 {this._navigatorView.sourceDeleted(this.uiSourceCode);return true;},_handleContextMenuEvent:function(event)
666 {this.select();this._navigatorView.handleFileContextMenu(event,this._uiSourceCode);},__proto__:WebInspector.BaseNavigatorTreeElement.prototype}
667 WebInspector.NavigatorTreeNode=function(id)
668 {this.id=id;this._children=new StringMap();}
669 WebInspector.NavigatorTreeNode.prototype={treeElement:function(){throw"Not implemented";},dispose:function(){},isRoot:function()
670 {return false;},hasChildren:function()
671 {return true;},populate:function()
672 {if(this.isPopulated())
673 return;if(this.parent)
674 this.parent.populate();this._populated=true;this.wasPopulated();},wasPopulated:function()
675 {var children=this.children();for(var i=0;i<children.length;++i)
676 this.treeElement().appendChild(children[i].treeElement());},didAddChild:function(node)
677 {if(this.isPopulated())
678 this.treeElement().appendChild(node.treeElement());},willRemoveChild:function(node)
679 {if(this.isPopulated())
680 this.treeElement().removeChild(node.treeElement());},isPopulated:function()
681 {return this._populated;},isEmpty:function()
682 {return!this._children.size();},child:function(id)
683 {return this._children.get(id)||null;},children:function()
684 {return this._children.values();},appendChild:function(node)
685 {this._children.put(node.id,node);node.parent=this;this.didAddChild(node);},removeChild:function(node)
686 {this.willRemoveChild(node);this._children.remove(node.id);delete node.parent;node.dispose();},reset:function()
687 {this._children.clear();}}
688 WebInspector.NavigatorRootTreeNode=function(navigatorView)
689 {WebInspector.NavigatorTreeNode.call(this,"");this._navigatorView=navigatorView;}
690 WebInspector.NavigatorRootTreeNode.prototype={isRoot:function()
691 {return true;},treeElement:function()
692 {return this._navigatorView._scriptsTree;},__proto__:WebInspector.NavigatorTreeNode.prototype}
693 WebInspector.NavigatorUISourceCodeTreeNode=function(navigatorView,uiSourceCode)
694 {WebInspector.NavigatorTreeNode.call(this,uiSourceCode.name());this._navigatorView=navigatorView;this._uiSourceCode=uiSourceCode;this._treeElement=null;}
695 WebInspector.NavigatorUISourceCodeTreeNode.prototype={uiSourceCode:function()
696 {return this._uiSourceCode;},updateIcon:function()
697 {if(this._treeElement)
698 this._treeElement.updateIcon();},treeElement:function()
699 {if(this._treeElement)
700 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);return this._treeElement;},updateTitle:function(ignoreIsDirty)
701 {if(!this._treeElement)
702 return;var titleText=this._uiSourceCode.displayName();if(!ignoreIsDirty&&(this._uiSourceCode.isDirty()||this._uiSourceCode.hasUnsavedCommittedChanges()))
703 titleText="*"+titleText;this._treeElement.titleText=titleText;},hasChildren:function()
704 {return false;},dispose:function()
705 {if(!this._treeElement)
706 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);},_titleChanged:function(event)
707 {this.updateTitle();},_workingCopyChanged:function(event)
708 {this.updateTitle();},_workingCopyCommitted:function(event)
709 {this.updateTitle();},reveal:function(select)
710 {this.parent.populate();this.parent.treeElement().expand();this._treeElement.reveal();if(select)
711 this._treeElement.select(true);},rename:function(callback)
712 {if(!this._treeElement)
713 return;var treeOutlineElement=this._treeElement.treeOutline.element;WebInspector.markBeingEdited(treeOutlineElement,true);function commitHandler(element,newTitle,oldTitle)
714 {if(newTitle!==oldTitle){this._treeElement.titleText=newTitle;this._uiSourceCode.rename(newTitle,renameCallback.bind(this));return;}
715 afterEditing.call(this,true);}
716 function renameCallback(success)
717 {if(!success){WebInspector.markBeingEdited(treeOutlineElement,false);this.updateTitle();this.rename(callback);return;}
718 afterEditing.call(this,true);}
719 function cancelHandler()
720 {afterEditing.call(this,false);}
721 function afterEditing(committed)
722 {WebInspector.markBeingEdited(treeOutlineElement,false);this.updateTitle();this._treeElement.treeOutline.childrenListElement.focus();if(callback)
723 callback(committed);}
724 var editingConfig=new WebInspector.InplaceEditor.Config(commitHandler.bind(this),cancelHandler.bind(this));this.updateTitle(true);WebInspector.InplaceEditor.startEditing(this._treeElement.titleElement,editingConfig);window.getSelection().setBaseAndExtent(this._treeElement.titleElement,0,this._treeElement.titleElement,1);},__proto__:WebInspector.NavigatorTreeNode.prototype}
725 WebInspector.NavigatorFolderTreeNode=function(navigatorView,project,id,type,folderPath,title)
726 {WebInspector.NavigatorTreeNode.call(this,id);this._navigatorView=navigatorView;this._project=project;this._type=type;this._folderPath=folderPath;this._title=title;}
727 WebInspector.NavigatorFolderTreeNode.prototype={treeElement:function()
728 {if(this._treeElement)
729 return this._treeElement;this._treeElement=this._createTreeElement(this._title,this);return this._treeElement;},_createTreeElement:function(title,node)
730 {var treeElement=new WebInspector.NavigatorFolderTreeElement(this._navigatorView,this._type,title);treeElement.setNode(node);return treeElement;},wasPopulated:function()
731 {if(!this._treeElement||this._treeElement._node!==this)
732 return;this._addChildrenRecursive();},_addChildrenRecursive:function()
733 {var children=this.children();for(var i=0;i<children.length;++i){var child=children[i];this.didAddChild(child);if(child instanceof WebInspector.NavigatorFolderTreeNode)
734 child._addChildrenRecursive();}},_shouldMerge:function(node)
735 {return this._type!==WebInspector.NavigatorTreeOutline.Types.Domain&&node instanceof WebInspector.NavigatorFolderTreeNode;},didAddChild:function(node)
736 {function titleForNode(node)
737 {return node._title;}
738 if(!this._treeElement)
739 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;}
740 var oldNode;if(children.length===2)
741 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);}
742 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;}
743 return;}
744 var oldTreeElement=this._treeElement;var treeElement=this._createTreeElement(titleText,this);for(var i=0;i<mergedToNodes.length;++i)
745 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)
746 treeElement.expand();}
747 if(this.isPopulated())
748 this._treeElement.appendChild(node.treeElement());},willRemoveChild:function(node)
749 {if(node._isMerged||!this.isPopulated())
750 return;this._treeElement.removeChild(node._treeElement);},__proto__:WebInspector.NavigatorTreeNode.prototype};WebInspector.RevisionHistoryView=function()
751 {WebInspector.VBox.call(this);this.registerRequiredCSS("revisionHistory.css");this.element.classList.add("revision-history-drawer");this.element.classList.add("outline-disclosure");this._uiSourceCodeItems=new Map();var olElement=this.element.createChild("ol");this._treeOutline=new TreeOutline(olElement);function populateRevisions(uiSourceCode)
752 {if(uiSourceCode.history.length)
753 this._createUISourceCodeItem(uiSourceCode);}
754 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);}
755 WebInspector.RevisionHistoryView.showHistory=function(uiSourceCode)
756 {if(!WebInspector.RevisionHistoryView._view)
757 WebInspector.RevisionHistoryView._view=new WebInspector.RevisionHistoryView();var view=WebInspector.RevisionHistoryView._view;WebInspector.inspectorView.showCloseableViewInDrawer("history",WebInspector.UIString("History"),view);view._revealUISourceCode(uiSourceCode);}
758 WebInspector.RevisionHistoryView.prototype={_createUISourceCodeItem:function(uiSourceCode)
759 {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;}}
760 if(i===this._treeOutline.children.length)
761 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);}
762 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)
763 {uiSourceCode.revertAndClearHistory(this._removeUISourceCode.bind(this));},_revisionAdded:function(event)
764 {var uiSourceCode=(event.data.uiSourceCode);var uiSourceCodeItem=this._uiSourceCodeItems.get(uiSourceCode);if(!uiSourceCodeItem){uiSourceCodeItem=this._createUISourceCodeItem(uiSourceCode);return;}
765 var historyLength=uiSourceCode.history.length;var historyItem=new WebInspector.RevisionHistoryTreeElement(uiSourceCode.history[historyLength-1],uiSourceCode.history[historyLength-2],false);if(uiSourceCodeItem.children.length)
766 uiSourceCodeItem.children[0].allowRevert();uiSourceCodeItem.insertChild(historyItem,0);},_revealUISourceCode:function(uiSourceCode)
767 {var uiSourceCodeItem=this._uiSourceCodeItems.get(uiSourceCode);if(uiSourceCodeItem){uiSourceCodeItem.reveal();uiSourceCodeItem.expand();}},_uiSourceCodeRemoved:function(event)
768 {var uiSourceCode=(event.data);this._removeUISourceCode(uiSourceCode);},_removeUISourceCode:function(uiSourceCode)
769 {var uiSourceCodeItem=this._uiSourceCodeItems.get(uiSourceCode);if(!uiSourceCodeItem)
770 return;this._treeOutline.removeChild(uiSourceCodeItem);this._uiSourceCodeItems.remove(uiSourceCode);},_projectWillReset:function(event)
771 {var project=event.data;project.uiSourceCodes().forEach(this._removeUISourceCode.bind(this));},__proto__:WebInspector.VBox.prototype}
772 WebInspector.RevisionHistoryTreeElement=function(revision,baseRevision,allowRevert)
773 {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)
774 this._revertElement.classList.add("hidden");}
775 WebInspector.RevisionHistoryTreeElement.prototype={onattach:function()
776 {this.listItemElement.classList.add("revision-history-revision");},onexpand:function()
777 {this.listItemElement.appendChild(this._revertElement);if(this._wasExpandedOnce)
778 return;this._wasExpandedOnce=true;this.childrenListElement.classList.add("source-code");if(this._baseRevision)
779 this._baseRevision.requestContent(step1.bind(this));else
780 this._revision.uiSourceCode.requestOriginalContent(step1.bind(this));function step1(baseContent)
781 {this._revision.requestContent(step2.bind(this,baseContent));}
782 function step2(baseContent,newContent)
783 {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;}
784 if(change==="insert"||(change==="replace"&&n<ne)){var lineNumber=n++;this._createLine(null,lineNumber,newLines[lineNumber],"added");lastWasSeparator=false;}
785 if(change==="equal"){b++;n++;if(!lastWasSeparator)
786 this._createLine(null,null,"    \u2026","separator");lastWasSeparator=true;}}}}},oncollapse:function()
787 {this._revertElement.remove();},_createLine:function(baseLineNumber,newLineNumber,lineContent,changeType)
788 {var child=new TreeElement("",null,false);child.selectable=false;this.appendChild(child);var lineElement=document.createElement("span");function appendLineNumber(lineNumber)
789 {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);}
790 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()
791 {this._revertElement.classList.remove("hidden");},__proto__:TreeElement.prototype};WebInspector.ScopeChainSidebarPane=function()
792 {WebInspector.SidebarPane.call(this,WebInspector.UIString("Scope Variables"));this._sections=[];this._expandedSections={};this._expandedProperties=[];}
793 WebInspector.ScopeChainSidebarPane.prototype={update:function(callFrame)
794 {this.bodyElement.removeChildren();if(!callFrame){var infoElement=document.createElement("div");infoElement.className="info";infoElement.textContent=WebInspector.UIString("Not Paused");this.bodyElement.appendChild(infoElement);return;}
795 for(var i=0;i<this._sections.length;++i){var section=this._sections[i];if(!section.title)
796 continue;if(section.expanded)
797 this._expandedSections[section.title]=true;else
798 delete this._expandedSections[section.title];}
799 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)
800 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&&!callFrame.isAsync()){var exceptionObject=(exception);extraProperties.push(new WebInspector.RemoteObjectProperty("<exception>",WebInspector.RemoteObject.fromPayload(exceptionObject)));}
801 if(callFrame.returnValue)
802 extraProperties.push(new WebInspector.RemoteObjectProperty("<return>",WebInspector.RemoteObject.fromPayload(callFrame.returnValue)));}
803 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;}
804 if(!title||title===subtitle)
805 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)
806 section.expanded=false;else if(!foundLocalScope||scope.type===DebuggerAgent.ScopeType.Local||title in this._expandedSections)
807 section.expanded=true;this._sections.push(section);this.bodyElement.appendChild(section.element);}},__proto__:WebInspector.SidebarPane.prototype}
808 WebInspector.ScopeVariableTreeElement=function(property)
809 {WebInspector.ObjectPropertyTreeElement.call(this,property);}
810 WebInspector.ScopeVariableTreeElement.prototype={onattach:function()
811 {WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);if(this.hasChildren&&this.propertyIdentifier in this.treeOutline.section.pane._expandedProperties)
812 this.expand();},onexpand:function()
813 {this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier]=true;},oncollapse:function()
814 {delete this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier];},get propertyIdentifier()
815 {if("_propertyIdentifier"in this)
816 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(workspace)
817 {WebInspector.Object.call(this);this._workspace=workspace;this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.shrinkableTabs=true;this._tabbedPane.element.classList.add("navigator-tabbed-pane");new WebInspector.ExtensibleTabbedPaneController(this._tabbedPane,"navigator-view",this._navigatorViewCreated.bind(this));this._navigatorViews=new StringMap();}
818 WebInspector.SourcesNavigator.Events={SourceSelected:"SourceSelected",SourceRenamed:"SourceRenamed"}
819 WebInspector.SourcesNavigator.prototype={_navigatorViewCreated:function(id,view)
820 {var navigatorView=(view);navigatorView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected,this._sourceSelected,this);navigatorView.addEventListener(WebInspector.NavigatorView.Events.ItemRenamed,this._sourceRenamed,this);this._navigatorViews.put(id,navigatorView);navigatorView.setWorkspace(this._workspace);},get view()
821 {return this._tabbedPane;},_navigatorViewIdForUISourceCode:function(uiSourceCode)
822 {var ids=this._navigatorViews.keys();for(var i=0;i<ids.length;++i){var id=ids[i]
823 var navigatorView=this._navigatorViews.get(id);if(navigatorView.accept(uiSourceCode))
824 return id;}
825 return null;},revealUISourceCode:function(uiSourceCode)
826 {var id=this._navigatorViewIdForUISourceCode(uiSourceCode);if(!id)
827 return;var navigatorView=this._navigatorViews.get(id);console.assert(navigatorView);navigatorView.revealUISourceCode(uiSourceCode,true);this._tabbedPane.selectTab(id);},_sourceSelected:function(event)
828 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.SourceSelected,event.data);},_sourceRenamed:function(event)
829 {this.dispatchEventToListeners(WebInspector.SourcesNavigator.Events.SourceRenamed,event.data);},__proto__:WebInspector.Object.prototype}
830 WebInspector.SnippetsNavigatorView=function()
831 {WebInspector.NavigatorView.call(this);}
832 WebInspector.SnippetsNavigatorView.prototype={accept:function(uiSourceCode)
833 {if(!WebInspector.NavigatorView.prototype.accept(uiSourceCode))
834 return false;return uiSourceCode.project().type()===WebInspector.projectTypes.Snippets;},handleContextMenu:function(event)
835 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("New"),this._handleCreateSnippet.bind(this));contextMenu.show();},handleFileContextMenu:function(event,uiSourceCode)
836 {var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Run"),this._handleEvaluateSnippet.bind(this,uiSourceCode));contextMenu.appendItem(WebInspector.UIString("Rename"),this.rename.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)
837 {if(uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets)
838 return;WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode);},_handleRemoveSnippet:function(uiSourceCode)
839 {if(uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets)
840 return;uiSourceCode.remove();},_handleCreateSnippet:function()
841 {this.create(WebInspector.scriptSnippetModel.project(),"")},sourceDeleted:function(uiSourceCode)
842 {this._handleRemoveSnippet(uiSourceCode);},__proto__:WebInspector.NavigatorView.prototype};WebInspector.SourcesSearchScope=function()
843 {this._searchId=0;this._workspace=WebInspector.workspace;}
844 WebInspector.SourcesSearchScope.prototype={performIndexing:function(progress,indexingFinishedCallback)
845 {this.stopSearch();var projects=this._workspace.projects().filter(this._filterOutServiceProjects);var barrier=new CallbackBarrier();var compositeProgress=new WebInspector.CompositeProgress(progress);progress.addEventListener(WebInspector.Progress.Events.Canceled,indexingCanceled);for(var i=0;i<projects.length;++i){var project=projects[i];var projectProgress=compositeProgress.createSubProgress(project.uiSourceCodes().length);project.indexContent(projectProgress,barrier.createCallback());}
846 barrier.callWhenDone(indexingFinishedCallback.bind(this,true));function indexingCanceled()
847 {indexingFinishedCallback(false);progress.done();}},_filterOutServiceProjects:function(project)
848 {return!project.isServiceProject()||project.type()===WebInspector.projectTypes.Formatter;},performSearch:function(searchConfig,progress,searchResultCallback,searchFinishedCallback)
849 {this.stopSearch();this._searchResultCallback=searchResultCallback;this._searchFinishedCallback=searchFinishedCallback;this._searchConfig=searchConfig;var projects=this._workspace.projects().filter(this._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);}
850 barrier.callWhenDone(this._searchFinishedCallback.bind(this,true));},_processMatchingFilesForProject:function(searchId,project,progress,callback,files)
851 {if(searchId!==this._searchId){this._searchFinishedCallback(false);return;}
852 if(!files.length){progress.done();callback();return;}
853 progress.setTotalWork(files.length);var fileIndex=0;var maxFileContentRequests=20;var callbacksLeft=0;for(var i=0;i<maxFileContentRequests&&i<files.length;++i)
854 scheduleSearchInNextFileOrFinish.call(this);function searchInNextFile(path)
855 {var uiSourceCode=project.uiSourceCode(path);if(!uiSourceCode){--callbacksLeft;progress.worked(1);scheduleSearchInNextFileOrFinish.call(this);return;}
856 uiSourceCode.requestContent(contentLoaded.bind(this,path));}
857 function scheduleSearchInNextFileOrFinish()
858 {if(fileIndex>=files.length){if(!callbacksLeft){progress.done();callback();return;}
859 return;}
860 ++callbacksLeft;var path=files[fileIndex++];setTimeout(searchInNextFile.bind(this,path),0);}
861 function contentLoaded(path,content)
862 {function matchesComparator(a,b)
863 {return a.lineNumber-b.lineNumber;}
864 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)
865 matches=matches.mergeOrdered(nextMatches,matchesComparator);}}
866 var uiSourceCode=project.uiSourceCode(path);if(matches&&uiSourceCode){var searchResult=new WebInspector.FileBasedSearchResultsPane.SearchResult(uiSourceCode,matches);this._searchResultCallback(searchResult);}
867 --callbacksLeft;scheduleSearchInNextFileOrFinish.call(this);}},stopSearch:function()
868 {++this._searchId;},createSearchResultsPane:function(searchConfig)
869 {return new WebInspector.FileBasedSearchResultsPane(searchConfig);}};WebInspector.StyleSheetOutlineDialog=function(uiSourceCode,selectItemCallback)
870 {WebInspector.SelectionDialogContentProvider.call(this);this._selectItemCallback=selectItemCallback;this._cssParser=new WebInspector.CSSParser();this._cssParser.addEventListener(WebInspector.CSSParser.Events.RulesParsed,this.refresh.bind(this));this._cssParser.parse(uiSourceCode.workingCopy());}
871 WebInspector.StyleSheetOutlineDialog.show=function(view,uiSourceCode,selectItemCallback)
872 {if(WebInspector.Dialog.currentInstance())
873 return null;var delegate=new WebInspector.StyleSheetOutlineDialog(uiSourceCode,selectItemCallback);var filteredItemSelectionDialog=new WebInspector.FilteredItemSelectionDialog(delegate);WebInspector.Dialog.show(view.element,filteredItemSelectionDialog);}
874 WebInspector.StyleSheetOutlineDialog.prototype={itemCount:function()
875 {return this._cssParser.rules().length;},itemKeyAt:function(itemIndex)
876 {var rule=this._cssParser.rules()[itemIndex];return rule.selectorText||rule.atRule;},itemScoreAt:function(itemIndex,query)
877 {var rule=this._cssParser.rules()[itemIndex];return-rule.lineNumber;},renderItem:function(itemIndex,query,titleElement,subtitleElement)
878 {var rule=this._cssParser.rules()[itemIndex];titleElement.textContent=rule.selectorText||rule.atRule;this.highlightRanges(titleElement,query);subtitleElement.textContent=":"+(rule.lineNumber+1);},selectItem:function(itemIndex,promptValue)
879 {var rule=this._cssParser.rules()[itemIndex];var lineNumber=rule.lineNumber;if(!isNaN(lineNumber)&&lineNumber>=0)
880 this._selectItemCallback(lineNumber,rule.columnNumber);},dispose:function()
881 {this._cssParser.dispose();},__proto__:WebInspector.SelectionDialogContentProvider.prototype};WebInspector.TabbedEditorContainerDelegate=function(){}
882 WebInspector.TabbedEditorContainerDelegate.prototype={viewForFile:function(uiSourceCode){},}
883 WebInspector.TabbedEditorContainer=function(delegate,settingName,placeholderText)
884 {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());}
885 WebInspector.TabbedEditorContainer.Events={EditorSelected:"EditorSelected",EditorClosed:"EditorClosed"}
886 WebInspector.TabbedEditorContainer._tabId=0;WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount=30;WebInspector.TabbedEditorContainer.prototype={get view()
887 {return this._tabbedPane;},get visibleView()
888 {return this._tabbedPane.visibleView;},show:function(parentElement)
889 {this._tabbedPane.show(parentElement);},showFile:function(uiSourceCode)
890 {this._innerShowFile(uiSourceCode,true);},closeFile:function(uiSourceCode)
891 {var tabId=this._tabIds.get(uiSourceCode);if(!tabId)
892 return;this._closeTabs([tabId]);},historyUISourceCodes:function()
893 {var uriToUISourceCode={};for(var id in this._files){var uiSourceCode=this._files[id];uriToUISourceCode[uiSourceCode.uri()]=uiSourceCode;}
894 var result=[];var uris=this._history._urls();for(var i=0;i<uris.length;++i){var uiSourceCode=uriToUISourceCode[uris[i]];if(uiSourceCode)
895 result.push(uiSourceCode);}
896 return result;},_addViewListeners:function()
897 {if(!this._currentView)
898 return;this._currentView.addEventListener(WebInspector.SourceFrame.Events.ScrollChanged,this._scrollChanged,this);this._currentView.addEventListener(WebInspector.SourceFrame.Events.SelectionChanged,this._selectionChanged,this);},_removeViewListeners:function()
899 {if(!this._currentView)
900 return;this._currentView.removeEventListener(WebInspector.SourceFrame.Events.ScrollChanged,this._scrollChanged,this);this._currentView.removeEventListener(WebInspector.SourceFrame.Events.SelectionChanged,this._selectionChanged,this);},_scrollChanged:function(event)
901 {var lineNumber=(event.data);this._history.updateScrollLineNumber(this._currentFile.uri(),lineNumber);this._history.save(this._previouslyViewedFilesSetting);},_selectionChanged:function(event)
902 {var range=(event.data);this._history.updateSelectionRange(this._currentFile.uri(),range);this._history.save(this._previouslyViewedFilesSetting);},_innerShowFile:function(uiSourceCode,userGesture)
903 {if(this._currentFile===uiSourceCode)
904 return;this._removeViewListeners();this._currentFile=uiSourceCode;var tabId=this._tabIds.get(uiSourceCode)||this._appendFileTab(uiSourceCode,userGesture);this._tabbedPane.selectTab(tabId,userGesture);if(userGesture)
905 this._editorSelectedByUserAction();this._currentView=this.visibleView;this._addViewListeners();var eventData={currentFile:this._currentFile,userGesture:userGesture};this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.EditorSelected,eventData);},_titleForFile:function(uiSourceCode)
906 {var maxDisplayNameLength=30;var title=uiSourceCode.displayName(true).trimMiddle(maxDisplayNameLength);if(uiSourceCode.isDirty()||uiSourceCode.hasUnsavedCommittedChanges())
907 title+="*";return title;},_maybeCloseTab:function(id,nextTabId)
908 {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)
909 this._tabbedPane.selectTab(nextTabId,true);this._tabbedPane.closeTab(id,true);return true;}
910 return false;},_closeTabs:function(ids)
911 {var dirtyTabs=[];var cleanTabs=[];for(var i=0;i<ids.length;++i){var id=ids[i];var uiSourceCode=this._files[id];if(uiSourceCode.isDirty())
912 dirtyTabs.push(id);else
913 cleanTabs.push(id);}
914 if(dirtyTabs.length)
915 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))
916 break;}},addUISourceCode:function(uiSourceCode)
917 {var uri=uiSourceCode.uri();if(this._userSelectedFiles)
918 return;var index=this._history.index(uri)
919 if(index===-1)
920 return;var tabId=this._tabIds.get(uiSourceCode)||this._appendFileTab(uiSourceCode,false);if(!this._currentFile)
921 return;if(!index){this._innerShowFile(uiSourceCode,false);return;}
922 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)
923 this._innerShowFile(uiSourceCode,false);},removeUISourceCode:function(uiSourceCode)
924 {this.removeUISourceCodes([uiSourceCode]);},removeUISourceCodes:function(uiSourceCodes)
925 {var tabIds=[];for(var i=0;i<uiSourceCodes.length;++i){var uiSourceCode=uiSourceCodes[i];var tabId=this._tabIds.get(uiSourceCode);if(tabId)
926 tabIds.push(tabId);}
927 this._tabbedPane.closeTabs(tabIds);},_editorClosedByUserAction:function(uiSourceCode)
928 {this._userSelectedFiles=true;this._history.remove(uiSourceCode.uri());this._updateHistory();},_editorSelectedByUserAction:function()
929 {this._userSelectedFiles=true;this._updateHistory();},_updateHistory:function()
930 {var tabIds=this._tabbedPane.lastOpenedTabIds(WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount);function tabIdToURI(tabId)
931 {return this._files[tabId].uri();}
932 this._history.update(tabIds.map(tabIdToURI.bind(this)));this._history.save(this._previouslyViewedFilesSetting);},_tooltipForFile:function(uiSourceCode)
933 {return uiSourceCode.originURL();},_appendFileTab:function(uiSourceCode,userGesture)
934 {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)
935 view.setSelection(savedSelectionRange);var savedScrollLineNumber=this._history.scrollLineNumber(uiSourceCode.uri());if(savedScrollLineNumber)
936 view.scrollToLine(savedScrollLineNumber);this._tabbedPane.appendTab(tabId,title,view,tooltip,userGesture);this._updateFileTitle(uiSourceCode);this._addUISourceCodeListeners(uiSourceCode);return tabId;},_tabClosed:function(event)
937 {var tabId=(event.data.tabId);var userGesture=(event.data.isUserGesture);var uiSourceCode=this._files[tabId];if(this._currentFile===uiSourceCode){this._removeViewListeners();delete this._currentView;delete this._currentFile;}
938 this._tabIds.remove(uiSourceCode);delete this._files[tabId];this._removeUISourceCodeListeners(uiSourceCode);this.dispatchEventToListeners(WebInspector.TabbedEditorContainer.Events.EditorClosed,uiSourceCode);if(userGesture)
939 this._editorClosedByUserAction(uiSourceCode);},_tabSelected:function(event)
940 {var tabId=(event.data.tabId);var userGesture=(event.data.isUserGesture);var uiSourceCode=this._files[tabId];this._innerShowFile(uiSourceCode,userGesture);},_addUISourceCodeListeners:function(uiSourceCode)
941 {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);},_removeUISourceCodeListeners:function(uiSourceCode)
942 {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);},_updateFileTitle:function(uiSourceCode)
943 {var tabId=this._tabIds.get(uiSourceCode);if(tabId){var title=this._titleForFile(uiSourceCode);this._tabbedPane.changeTabTitle(tabId,title);if(uiSourceCode.hasUnsavedCommittedChanges())
944 this._tabbedPane.setTabIcon(tabId,"editor-container-unsaved-committed-changes-icon",WebInspector.UIString("Changes to this file were not saved to file system."));else
945 this._tabbedPane.setTabIcon(tabId,"");}},_uiSourceCodeTitleChanged:function(event)
946 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);this._updateHistory();},_uiSourceCodeWorkingCopyChanged:function(event)
947 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},_uiSourceCodeWorkingCopyCommitted:function(event)
948 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},_uiSourceCodeSavedStateUpdated:function(event)
949 {var uiSourceCode=(event.target);this._updateFileTitle(uiSourceCode);},reset:function()
950 {delete this._userSelectedFiles;},_generateTabId:function()
951 {return"tab_"+(WebInspector.TabbedEditorContainer._tabId++);},currentFile:function()
952 {return this._currentFile;},__proto__:WebInspector.Object.prototype}
953 WebInspector.TabbedEditorContainer.HistoryItem=function(url,selectionRange,scrollLineNumber)
954 {this.url=url;this._isSerializable=url.length<WebInspector.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit;this.selectionRange=selectionRange;this.scrollLineNumber=scrollLineNumber;}
955 WebInspector.TabbedEditorContainer.HistoryItem.serializableUrlLengthLimit=4096;WebInspector.TabbedEditorContainer.HistoryItem.fromObject=function(serializedHistoryItem)
956 {var selectionRange=serializedHistoryItem.selectionRange?WebInspector.TextRange.fromObject(serializedHistoryItem.selectionRange):undefined;return new WebInspector.TabbedEditorContainer.HistoryItem(serializedHistoryItem.url,selectionRange,serializedHistoryItem.scrollLineNumber);}
957 WebInspector.TabbedEditorContainer.HistoryItem.prototype={serializeToObject:function()
958 {if(!this._isSerializable)
959 return null;var serializedHistoryItem={};serializedHistoryItem.url=this.url;serializedHistoryItem.selectionRange=this.selectionRange;serializedHistoryItem.scrollLineNumber=this.scrollLineNumber;return serializedHistoryItem;}}
960 WebInspector.TabbedEditorContainer.History=function(items)
961 {this._items=items;this._rebuildItemIndex();}
962 WebInspector.TabbedEditorContainer.History.fromObject=function(serializedHistory)
963 {var items=[];for(var i=0;i<serializedHistory.length;++i)
964 items.push(WebInspector.TabbedEditorContainer.HistoryItem.fromObject(serializedHistory[i]));return new WebInspector.TabbedEditorContainer.History(items);}
965 WebInspector.TabbedEditorContainer.History.prototype={index:function(url)
966 {var index=this._itemsIndex[url];if(typeof index==="number")
967 return index;return-1;},_rebuildItemIndex:function()
968 {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)
969 {var index=this.index(url);return index!==-1?this._items[index].selectionRange:undefined;},updateSelectionRange:function(url,selectionRange)
970 {if(!selectionRange)
971 return;var index=this.index(url);if(index===-1)
972 return;this._items[index].selectionRange=selectionRange;},scrollLineNumber:function(url)
973 {var index=this.index(url);return index!==-1?this._items[index].scrollLineNumber:undefined;},updateScrollLineNumber:function(url,scrollLineNumber)
974 {var index=this.index(url);if(index===-1)
975 return;this._items[index].scrollLineNumber=scrollLineNumber;},update:function(urls)
976 {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
977 item=new WebInspector.TabbedEditorContainer.HistoryItem(urls[i]);this._items.unshift(item);this._rebuildItemIndex();}},remove:function(url)
978 {var index=this.index(url);if(index!==-1){this._items.splice(index,1);this._rebuildItemIndex();}},save:function(setting)
979 {setting.set(this._serializeToObject());},_serializeToObject:function()
980 {var serializedHistory=[];for(var i=0;i<this._items.length;++i){var serializedItem=this._items[i].serializeToObject();if(serializedItem)
981 serializedHistory.push(serializedItem);if(serializedHistory.length===WebInspector.TabbedEditorContainer.maximalPreviouslyViewedFilesCount)
982 break;}
983 return serializedHistory;},_urls:function()
984 {var result=[];for(var i=0;i<this._items.length;++i)
985 result.push(this._items[i].url);return result;}}
986 WebInspector.EditorContainerTabDelegate=function(editorContainer)
987 {this._editorContainer=editorContainer;}
988 WebInspector.EditorContainerTabDelegate.prototype={closeTabs:function(tabbedPane,ids)
989 {this._editorContainer._closeTabs(ids);}};WebInspector.WatchExpressionsSidebarPane=function()
990 {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;}
991 WebInspector.WatchExpressionsSidebarPane.prototype={wasShown:function()
992 {this._refreshExpressionsIfNeeded();},reset:function()
993 {this.refreshExpressions();},refreshExpressions:function()
994 {this._requiresUpdate=true;this._refreshExpressionsIfNeeded();},addExpression:function(expression)
995 {this.section.addExpression(expression);this.expand();},_refreshExpressionsIfNeeded:function()
996 {if(this._requiresUpdate&&this.isShowing()){this.section.update();delete this._requiresUpdate;}else
997 this._requiresUpdate=true;},_addButtonClicked:function(event)
998 {event.consume();this.expand();this.section.addNewExpressionAndEdit();},_refreshButtonClicked:function(event)
999 {event.consume();this.refreshExpressions();},__proto__:WebInspector.SidebarPane.prototype}
1000 WebInspector.WatchExpressionsSection=function()
1001 {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);}
1002 WebInspector.WatchExpressionsSection.NewWatchExpression="\xA0";WebInspector.WatchExpressionsSection.prototype={update:function(e)
1003 {if(e)
1004 e.consume();function appendResult(expression,watchIndex,result,wasThrown)
1005 {if(!result)
1006 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)
1007 treeElement.startEditing();}
1008 if(this._lastMouseMovePageY)
1009 this._updateHoveredElement(this._lastMouseMovePageY);}}
1010 RuntimeAgent.releaseObjectGroup(this._watchObjectGroupId)
1011 var properties=[];var propertyCount=0;for(var i=0;i<this.watchExpressions.length;++i){if(!this.watchExpressions[i])
1012 continue;++propertyCount;}
1013 for(var i=0;i<this.watchExpressions.length;++i){var expression=this.watchExpressions[i];if(!expression)
1014 continue;WebInspector.runtimeModel.evaluate(expression,this._watchObjectGroupId,false,true,false,false,appendResult.bind(this,expression,i));}
1015 if(!propertyCount){if(!this.emptyElement.parentNode)
1016 this.element.appendChild(this.emptyElement);}else{if(this.emptyElement.parentNode)
1017 this.element.removeChild(this.emptyElement);}
1018 this.expanded=(propertyCount!=0);},addExpression:function(expression)
1019 {this.watchExpressions.push(expression);this.saveExpressions();this.update();},addNewExpressionAndEdit:function()
1020 {this._newExpressionAdded=true;this.watchExpressions.push(WebInspector.WatchExpressionsSection.NewWatchExpression);this.update();},_sectionDoubleClick:function(event)
1021 {if(event.target!==this.element&&event.target!==this.propertiesElement&&event.target!==this.emptyElement)
1022 return;event.consume();this.addNewExpressionAndEdit();},updateExpression:function(element,value)
1023 {if(value===null){var index=element.property.watchIndex;this.watchExpressions.splice(index,1);}
1024 else
1025 this.watchExpressions[element.property.watchIndex]=value;this.saveExpressions();this.update();},_deleteAllExpressions:function()
1026 {this.watchExpressions=[];this.saveExpressions();this.update();},findAddedTreeElement:function()
1027 {var children=this.propertiesTreeOutline.children;for(var i=0;i<children.length;++i){if(children[i].property.name===WebInspector.WatchExpressionsSection.NewWatchExpression)
1028 return children[i];}
1029 return null;},saveExpressions:function()
1030 {var toSave=[];for(var i=0;i<this.watchExpressions.length;i++)
1031 if(this.watchExpressions[i])
1032 toSave.push(this.watchExpressions[i]);WebInspector.settings.watchExpressions.set(toSave);return toSave.length;},_mouseMove:function(e)
1033 {if(this.propertiesElement.firstChild)
1034 this._updateHoveredElement(e.pageY);},_mouseOut:function()
1035 {if(this._hoveredElement){this._hoveredElement.classList.remove("hovered");delete this._hoveredElement;}
1036 delete this._lastMouseMovePageY;},_updateHoveredElement:function(pageY)
1037 {var candidateElement=this.propertiesElement.firstChild;while(true){var next=candidateElement.nextSibling;while(next&&!next.clientHeight)
1038 next=next.nextSibling;if(!next||next.totalOffsetTop()>pageY)
1039 break;candidateElement=next;}
1040 if(this._hoveredElement!==candidateElement){if(this._hoveredElement)
1041 this._hoveredElement.classList.remove("hovered");if(candidateElement)
1042 candidateElement.classList.add("hovered");this._hoveredElement=candidateElement;}
1043 this._lastMouseMovePageY=pageY;},_emptyElementContextMenu:function(event)
1044 {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}
1045 WebInspector.WatchExpressionsSection.CompareProperties=function(propertyA,propertyB)
1046 {if(propertyA.watchIndex==propertyB.watchIndex)
1047 return 0;else if(propertyA.watchIndex<propertyB.watchIndex)
1048 return-1;else
1049 return 1;}
1050 WebInspector.WatchExpressionTreeElement=function(property)
1051 {WebInspector.ObjectPropertyTreeElement.call(this,property);}
1052 WebInspector.WatchExpressionTreeElement.prototype={onexpand:function()
1053 {WebInspector.ObjectPropertyTreeElement.prototype.onexpand.call(this);this.treeOutline.section._expandedExpressions[this._expression()]=true;},oncollapse:function()
1054 {WebInspector.ObjectPropertyTreeElement.prototype.oncollapse.call(this);delete this.treeOutline.section._expandedExpressions[this._expression()];},onattach:function()
1055 {WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);if(this.treeOutline.section._expandedExpressions[this._expression()])
1056 this.expanded=true;},_expression:function()
1057 {return this.property.name;},update:function()
1058 {WebInspector.ObjectPropertyTreeElement.prototype.update.call(this);if(this.property.wasThrown){this.valueElement.textContent=WebInspector.UIString("<not available>");this.listItemElement.classList.add("dimmed");}else
1059 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)
1060 {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));}
1061 if(this.treeOutline.section.watchExpressions.length>1)
1062 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Delete all watch expressions":"Delete All Watch Expressions"),this._deleteAllButtonClicked.bind(this));},_contextMenu:function(event)
1063 {var contextMenu=new WebInspector.ContextMenu(event);this.populateContextMenu(contextMenu);contextMenu.show();},_deleteAllButtonClicked:function()
1064 {this.treeOutline.section._deleteAllExpressions();},_deleteButtonClicked:function()
1065 {this.treeOutline.section.updateExpression(this,null);},renderPromptAsBlock:function()
1066 {return true;},elementAndValueToEdit:function(event)
1067 {return[this.nameElement,this.property.name.trim()];},editingCancelled:function(element,context)
1068 {if(!context.elementToEdit.textContent)
1069 this.treeOutline.section.updateExpression(this,null);WebInspector.ObjectPropertyTreeElement.prototype.editingCancelled.call(this,element,context);},applyExpression:function(expression,updateInterface)
1070 {expression=expression.trim();if(!expression)
1071 expression=null;this.property.name=expression;this.treeOutline.section.updateExpression(this,expression);},__proto__:WebInspector.ObjectPropertyTreeElement.prototype}
1072 WebInspector.WatchedPropertyTreeElement=function(property)
1073 {WebInspector.ObjectPropertyTreeElement.call(this,property);}
1074 WebInspector.WatchedPropertyTreeElement.prototype={onattach:function()
1075 {WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);if(this.hasChildren&&this.propertyPath()in this.treeOutline.section._expandedProperties)
1076 this.expand();},onexpand:function()
1077 {WebInspector.ObjectPropertyTreeElement.prototype.onexpand.call(this);this.treeOutline.section._expandedProperties[this.propertyPath()]=true;},oncollapse:function()
1078 {WebInspector.ObjectPropertyTreeElement.prototype.oncollapse.call(this);delete this.treeOutline.section._expandedProperties[this.propertyPath()];},__proto__:WebInspector.ObjectPropertyTreeElement.prototype};WebInspector.WorkersSidebarPane=function()
1079 {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")
1080 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={};var threadList=WebInspector.workerManager.threadsList();for(var i=0;i<threadList.length;++i){var threadId=threadList[i];if(threadId===WebInspector.WorkerManager.MainThreadId)
1081 continue;this._addWorker(threadId,WebInspector.workerManager.threadUrl(threadId));}
1082 WebInspector.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerAdded,this._workerAdded,this);WebInspector.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerRemoved,this._workerRemoved,this);WebInspector.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkersCleared,this._workersCleared,this);}
1083 WebInspector.WorkersSidebarPane.prototype={_workerAdded:function(event)
1084 {this._addWorker(event.data.workerId,event.data.url);},_workerRemoved:function(event)
1085 {this._idToWorkerItem[event.data].remove();delete this._idToWorkerItem[event.data];},_workersCleared:function(event)
1086 {this._idToWorkerItem={};this._workerListElement.removeChildren();},_addWorker:function(workerId,url)
1087 {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)
1088 {event.preventDefault();WebInspector.workerFrontendManager.openWorkerInspector(workerId);},_autoattachToWorkersClicked:function(event)
1089 {WorkerAgent.setAutoconnectToWorkers(this._enableWorkersCheckbox.checked);},__proto__:WebInspector.SidebarPane.prototype};WebInspector.ThreadsToolbar=function()
1090 {this.element=document.createElement("div");this.element.className="status-bar scripts-debug-toolbar threads-toolbar hidden";this._comboBox=new WebInspector.StatusBarComboBox(this._onComboBoxSelectionChange.bind(this));this.element.appendChild(this._comboBox.element);this._reset();if(WebInspector.experimentsSettings.workersInMainWindow.isEnabled()){WebInspector.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerAdded,this._workerAdded,this);WebInspector.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkerRemoved,this._workerRemoved,this);WebInspector.workerManager.addEventListener(WebInspector.WorkerManager.Events.WorkersCleared,this._workersCleared,this);}}
1091 WebInspector.ThreadsToolbar.prototype={_reset:function()
1092 {if(!WebInspector.experimentsSettings.workersInMainWindow.isEnabled())
1093 return;this._threadIdToOption={};var connectedThreads=WebInspector.workerManager.threadsList();for(var i=0;i<connectedThreads.length;++i){var threadId=connectedThreads[i];this._addOption(threadId,WebInspector.workerManager.threadUrl(threadId));}
1094 this._alterVisibility();this._comboBox.select(this._threadIdToOption[WebInspector.workerManager.selectedThreadId()]);},_addOption:function(workerId,url)
1095 {var option=this._comboBox.createOption(url,"",String(workerId));this._threadIdToOption[workerId]=option;},_workerAdded:function(event)
1096 {var data=(event.data);this._addOption(data.workerId,data.url);this._alterVisibility();},_workerRemoved:function(event)
1097 {var data=(event.data);this._comboBox.removeOption(this._threadIdToOption[data.workerId]);delete this._threadIdToOption[data.workerId];this._alterVisibility();},_workersCleared:function()
1098 {this._comboBox.removeOptions();this._reset();},_onComboBoxSelectionChange:function()
1099 {var selectedOption=this._comboBox.selectedOption();if(!selectedOption)
1100 return;WebInspector.workerManager.setSelectedThreadId(parseInt(selectedOption.value,10));},_alterVisibility:function()
1101 {var hidden=this._comboBox.size()===1;this.element.classList.toggle("hidden",hidden);}};WebInspector.FormatterScriptMapping=function(workspace,debuggerModel)
1102 {this._workspace=workspace;this._debuggerModel=debuggerModel;this._init();this._projectDelegate=new WebInspector.FormatterProjectDelegate();this._workspace.addProject(this._projectDelegate);this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared,this._debuggerReset,this);}
1103 WebInspector.FormatterScriptMapping.prototype={rawLocationToUILocation:function(rawLocation)
1104 {var debuggerModelLocation=(rawLocation);var script=this._debuggerModel.scriptForId(debuggerModelLocation.scriptId);var uiSourceCode=this._uiSourceCodes.get(script);if(!uiSourceCode)
1105 return null;var formatData=this._formatData.get(uiSourceCode);if(!formatData)
1106 return null;var mapping=formatData.mapping;var lineNumber=debuggerModelLocation.lineNumber;var columnNumber=debuggerModelLocation.columnNumber||0;var formattedLocation=mapping.originalToFormatted(lineNumber,columnNumber);return new WebInspector.UILocation(uiSourceCode,formattedLocation[0],formattedLocation[1]);},uiLocationToRawLocation:function(uiSourceCode,lineNumber,columnNumber)
1107 {var formatData=this._formatData.get(uiSourceCode);if(!formatData)
1108 return null;var originalLocation=formatData.mapping.formattedToOriginal(lineNumber,columnNumber)
1109 return this._debuggerModel.createRawLocation(formatData.scripts[0],originalLocation[0],originalLocation[1]);},isIdentity:function()
1110 {return false;},_scriptsForUISourceCode:function(uiSourceCode)
1111 {function isInlineScript(script)
1112 {return script.isInlineScript();}
1113 if(uiSourceCode.contentType()===WebInspector.resourceTypes.Document)
1114 return this._debuggerModel.scriptsForSourceURL(uiSourceCode.url).filter(isInlineScript);if(uiSourceCode.contentType()===WebInspector.resourceTypes.Script){var rawLocation=uiSourceCode.uiLocationToRawLocation(0,0);return rawLocation?[this._debuggerModel.scriptForId(rawLocation.scriptId)]:[];}
1115 return[];},_init:function()
1116 {this._uiSourceCodes=new Map();this._formattedPaths=new StringMap();this._formatData=new Map();},_debuggerReset:function()
1117 {var formattedPaths=this._formattedPaths.values();for(var i=0;i<formattedPaths.length;++i)
1118 this._projectDelegate._removeFormatted(formattedPaths[i]);this._init();},_performUISourceCodeScriptFormatting:function(uiSourceCode,callback)
1119 {var path=this._formattedPaths.get(uiSourceCode.project().id()+":"+uiSourceCode.path());if(path){var uiSourceCodePath=path;var formattedUISourceCode=this._workspace.uiSourceCode(this._projectDelegate.id(),uiSourceCodePath);var formatData=formattedUISourceCode?this._formatData.get(formattedUISourceCode):null;if(!formatData)
1120 callback(null);else
1121 callback(formattedUISourceCode,formatData.mapping);return;}
1122 uiSourceCode.requestContent(contentLoaded.bind(this));function contentLoaded(content)
1123 {var formatter=WebInspector.Formatter.createFormatter(uiSourceCode.contentType());formatter.formatContent(uiSourceCode.highlighterType(),content||"",innerCallback.bind(this));}
1124 function innerCallback(formattedContent,formatterMapping)
1125 {var scripts=this._scriptsForUISourceCode(uiSourceCode);if(!scripts.length){callback(null);return;}
1126 var name;if(uiSourceCode.contentType()===WebInspector.resourceTypes.Document)
1127 name=uiSourceCode.displayName();else
1128 name=uiSourceCode.name()||scripts[0].scriptId;path=this._projectDelegate._addFormatted(name,uiSourceCode.url,uiSourceCode.contentType(),formattedContent);var formattedUISourceCode=(this._workspace.uiSourceCode(this._projectDelegate.id(),path));var formatData=new WebInspector.FormatterScriptMapping.FormatData(uiSourceCode.project().id(),uiSourceCode.path(),formatterMapping,scripts);this._formatData.put(formattedUISourceCode,formatData);this._formattedPaths.put(uiSourceCode.project().id()+":"+uiSourceCode.path(),path);for(var i=0;i<scripts.length;++i){this._uiSourceCodes.put(scripts[i],formattedUISourceCode);scripts[i].pushSourceMapping(this);}
1129 formattedUISourceCode.setSourceMapping(this);callback(formattedUISourceCode,formatterMapping);}},_discardFormattedUISourceCodeScript:function(formattedUISourceCode)
1130 {var formatData=this._formatData.get(formattedUISourceCode);if(!formatData)
1131 return null;this._formatData.remove(formattedUISourceCode);this._formattedPaths.remove(formatData.projectId+":"+formatData.path);for(var i=0;i<formatData.scripts.length;++i){this._uiSourceCodes.remove(formatData.scripts[i]);formatData.scripts[i].popSourceMapping();}
1132 this._projectDelegate._removeFormatted(formattedUISourceCode.path());return formatData.mapping;},}
1133 WebInspector.FormatterScriptMapping.FormatData=function(projectId,path,mapping,scripts)
1134 {this.projectId=projectId;this.path=path;this.mapping=mapping;this.scripts=scripts;}
1135 WebInspector.FormatterProjectDelegate=function()
1136 {WebInspector.ContentProviderBasedProjectDelegate.call(this,WebInspector.projectTypes.Formatter);}
1137 WebInspector.FormatterProjectDelegate.prototype={id:function()
1138 {return"formatter:";},displayName:function()
1139 {return"formatter";},_addFormatted:function(name,sourceURL,contentType,content)
1140 {var contentProvider=new WebInspector.StaticContentProvider(contentType,content);return this.addContentProvider(sourceURL,name+":formatted","deobfuscated:"+sourceURL,contentProvider,false,false);},_removeFormatted:function(path)
1141 {this.removeFile(path);},__proto__:WebInspector.ContentProviderBasedProjectDelegate.prototype}
1142 WebInspector.ScriptFormatterEditorAction=function()
1143 {this._scriptMapping=new WebInspector.FormatterScriptMapping(WebInspector.workspace,WebInspector.debuggerModel);}
1144 WebInspector.ScriptFormatterEditorAction.prototype={_editorSelected:function(event)
1145 {var uiSourceCode=(event.data);this._updateButton(uiSourceCode);},_editorClosed:function(event)
1146 {var uiSourceCode=(event.data.uiSourceCode);var wasSelected=(event.data.wasSelected);if(wasSelected)
1147 this._updateButton(null);this._discardFormattedUISourceCodeScript(uiSourceCode);},_updateButton:function(uiSourceCode)
1148 {this._button.element.classList.toggle("hidden",!this._isFormatableScript(uiSourceCode));},button:function(sourcesView)
1149 {if(this._button)
1150 return this._button.element;this._sourcesView=sourcesView;this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSelected,this._editorSelected.bind(this));this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorClosed,this._editorClosed.bind(this));this._button=new WebInspector.StatusBarButton(WebInspector.UIString("Pretty print"),"sources-toggle-pretty-print-status-bar-item");this._button.toggled=false;this._button.addEventListener("click",this._toggleFormatScriptSource,this);this._updateButton(null);return this._button.element;},_isFormatableScript:function(uiSourceCode)
1151 {if(!uiSourceCode)
1152 return false;var projectType=uiSourceCode.project().type();if(projectType!==WebInspector.projectTypes.Network&&projectType!==WebInspector.projectTypes.Debugger)
1153 return false;var contentType=uiSourceCode.contentType();return contentType===WebInspector.resourceTypes.Script||contentType===WebInspector.resourceTypes.Document;},_toggleFormatScriptSource:function()
1154 {var uiSourceCode=this._sourcesView.currentUISourceCode();if(!this._isFormatableScript(uiSourceCode))
1155 return;this._formatUISourceCodeScript(uiSourceCode);WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.TogglePrettyPrint,enabled:true,url:uiSourceCode.originURL()});},_formatUISourceCodeScript:function(uiSourceCode)
1156 {this._scriptMapping._performUISourceCodeScriptFormatting(uiSourceCode,innerCallback.bind(this));function innerCallback(formattedUISourceCode,mapping)
1157 {if(!formattedUISourceCode)
1158 return;if(uiSourceCode!==this._sourcesView.currentUISourceCode())
1159 return;var sourceFrame=this._sourcesView.viewForFile(uiSourceCode);var start=[0,0];if(sourceFrame){var selection=sourceFrame.selection();start=mapping.originalToFormatted(selection.startLine,selection.startColumn);}
1160 this._sourcesView.showSourceLocation(formattedUISourceCode,start[0],start[1]);this._updateButton(formattedUISourceCode);}},_discardFormattedUISourceCodeScript:function(uiSourceCode)
1161 {this._scriptMapping._discardFormattedUISourceCodeScript(uiSourceCode);}};WebInspector.InplaceFormatterEditorAction=function()
1162 {}
1163 WebInspector.InplaceFormatterEditorAction.prototype={_editorSelected:function(event)
1164 {var uiSourceCode=(event.data);this._updateButton(uiSourceCode);},_editorClosed:function(event)
1165 {var wasSelected=(event.data.wasSelected);if(wasSelected)
1166 this._updateButton(null);},_updateButton:function(uiSourceCode)
1167 {this._button.element.classList.toggle("hidden",!this._isFormattable(uiSourceCode));},button:function(sourcesView)
1168 {if(this._button)
1169 return this._button.element;this._sourcesView=sourcesView;this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSelected,this._editorSelected.bind(this));this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorClosed,this._editorClosed.bind(this));this._button=new WebInspector.StatusBarButton(WebInspector.UIString("Format"),"sources-toggle-pretty-print-status-bar-item");this._button.toggled=false;this._button.addEventListener("click",this._formatSourceInPlace,this);this._updateButton(null);return this._button.element;},_isFormattable:function(uiSourceCode)
1170 {if(!uiSourceCode)
1171 return false;return uiSourceCode.contentType()===WebInspector.resourceTypes.Stylesheet||uiSourceCode.project().type()===WebInspector.projectTypes.Snippets;},_formatSourceInPlace:function()
1172 {var uiSourceCode=this._sourcesView.currentUISourceCode();if(!this._isFormattable(uiSourceCode))
1173 return;if(uiSourceCode.isDirty())
1174 contentLoaded.call(this,uiSourceCode.workingCopy());else
1175 uiSourceCode.requestContent(contentLoaded.bind(this));function contentLoaded(content)
1176 {var formatter=WebInspector.Formatter.createFormatter(uiSourceCode.contentType());formatter.formatContent(uiSourceCode.highlighterType(),content||"",innerCallback.bind(this));}
1177 function innerCallback(formattedContent,formatterMapping)
1178 {if(uiSourceCode.workingCopy()===formattedContent)
1179 return;var sourceFrame=this._sourcesView.viewForFile(uiSourceCode);var start=[0,0];if(sourceFrame){var selection=sourceFrame.selection();start=formatterMapping.originalToFormatted(selection.startLine,selection.startColumn);}
1180 uiSourceCode.setWorkingCopy(formattedContent);this._sourcesView.showSourceLocation(uiSourceCode,start[0],start[1]);}},};WebInspector.Formatter=function()
1181 {}
1182 WebInspector.Formatter.createFormatter=function(contentType)
1183 {if(contentType===WebInspector.resourceTypes.Script||contentType===WebInspector.resourceTypes.Document||contentType===WebInspector.resourceTypes.Stylesheet)
1184 return new WebInspector.ScriptFormatter();return new WebInspector.IdentityFormatter();}
1185 WebInspector.Formatter.locationToPosition=function(lineEndings,lineNumber,columnNumber)
1186 {var position=lineNumber?lineEndings[lineNumber-1]+1:0;return position+columnNumber;}
1187 WebInspector.Formatter.positionToLocation=function(lineEndings,position)
1188 {var lineNumber=lineEndings.upperBound(position-1);if(!lineNumber)
1189 var columnNumber=position;else
1190 var columnNumber=position-lineEndings[lineNumber-1]-1;return[lineNumber,columnNumber];}
1191 WebInspector.Formatter.prototype={formatContent:function(mimeType,content,callback)
1192 {}}
1193 WebInspector.ScriptFormatter=function()
1194 {this._tasks=[];}
1195 WebInspector.ScriptFormatter.prototype={formatContent:function(mimeType,content,callback)
1196 {content=content.replace(/\r\n?|[\n\u2028\u2029]/g,"\n").replace(/^\uFEFF/,'');const method="format";var parameters={mimeType:mimeType,content:content,indentString:WebInspector.settings.textEditorIndent.get()};this._tasks.push({data:parameters,callback:callback});this._worker.postMessage({method:method,params:parameters});},_didFormatContent:function(event)
1197 {var task=this._tasks.shift();var originalContent=task.data.content;var formattedContent=event.data.content;var mapping=event.data["mapping"];var sourceMapping=new WebInspector.FormatterSourceMappingImpl(originalContent.lineEndings(),formattedContent.lineEndings(),mapping);task.callback(formattedContent,sourceMapping);},get _worker()
1198 {if(!this._cachedWorker){this._cachedWorker=new Worker("ScriptFormatterWorker.js");this._cachedWorker.onmessage=(this._didFormatContent.bind(this));}
1199 return this._cachedWorker;}}
1200 WebInspector.IdentityFormatter=function()
1201 {this._tasks=[];}
1202 WebInspector.IdentityFormatter.prototype={formatContent:function(mimeType,content,callback)
1203 {callback(content,new WebInspector.IdentityFormatterSourceMapping());}}
1204 WebInspector.FormatterMappingPayload=function()
1205 {this.original=[];this.formatted=[];}
1206 WebInspector.FormatterSourceMapping=function()
1207 {}
1208 WebInspector.FormatterSourceMapping.prototype={originalToFormatted:function(lineNumber,columnNumber){},formattedToOriginal:function(lineNumber,columnNumber){}}
1209 WebInspector.IdentityFormatterSourceMapping=function()
1210 {}
1211 WebInspector.IdentityFormatterSourceMapping.prototype={originalToFormatted:function(lineNumber,columnNumber)
1212 {return[lineNumber,columnNumber||0];},formattedToOriginal:function(lineNumber,columnNumber)
1213 {return[lineNumber,columnNumber||0];}}
1214 WebInspector.FormatterSourceMappingImpl=function(originalLineEndings,formattedLineEndings,mapping)
1215 {this._originalLineEndings=originalLineEndings;this._formattedLineEndings=formattedLineEndings;this._mapping=mapping;}
1216 WebInspector.FormatterSourceMappingImpl.prototype={originalToFormatted:function(lineNumber,columnNumber)
1217 {var originalPosition=WebInspector.Formatter.locationToPosition(this._originalLineEndings,lineNumber,columnNumber||0);var formattedPosition=this._convertPosition(this._mapping.original,this._mapping.formatted,originalPosition||0);return WebInspector.Formatter.positionToLocation(this._formattedLineEndings,formattedPosition);},formattedToOriginal:function(lineNumber,columnNumber)
1218 {var formattedPosition=WebInspector.Formatter.locationToPosition(this._formattedLineEndings,lineNumber,columnNumber||0);var originalPosition=this._convertPosition(this._mapping.formatted,this._mapping.original,formattedPosition);return WebInspector.Formatter.positionToLocation(this._originalLineEndings,originalPosition||0);},_convertPosition:function(positions1,positions2,position)
1219 {var index=positions1.upperBound(position)-1;var convertedPosition=positions2[index]+position-positions1[index];if(index<positions2.length-1&&convertedPosition>positions2[index+1])
1220 convertedPosition=positions2[index+1];return convertedPosition;}};WebInspector.SourcesView=function(workspace,sourcesPanel)
1221 {WebInspector.VBox.call(this);this.registerRequiredCSS("sourcesView.css");this.element.id="sources-panel-sources-view";this.setMinimumSize(50,25);this._workspace=workspace;this._sourcesPanel=sourcesPanel;this._searchableView=new WebInspector.SearchableView(this);this._searchableView.setMinimalSearchQuerySize(0);this._searchableView.show(this.element);this._sourceFramesByUISourceCode=new Map();var tabbedEditorPlaceholderText=WebInspector.isMac()?WebInspector.UIString("Hit Cmd+O to open a file"):WebInspector.UIString("Hit Ctrl+O to open a file");this._editorContainer=new WebInspector.TabbedEditorContainer(this,"previouslyViewedFiles",tabbedEditorPlaceholderText);this._editorContainer.show(this._searchableView.element);this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorSelected,this._editorSelected,this);this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorClosed,this._editorClosed,this);this._historyManager=new WebInspector.EditingLocationHistoryManager(this,this.currentSourceFrame.bind(this));this._scriptViewStatusBarItemsContainer=document.createElement("div");this._scriptViewStatusBarItemsContainer.className="inline-block";this._scriptViewStatusBarTextContainer=document.createElement("div");this._scriptViewStatusBarTextContainer.className="hbox";this._statusBarContainerElement=this.element.createChild("div","sources-status-bar");function appendButtonForExtension(EditorAction)
1222 {this._statusBarContainerElement.appendChild(EditorAction.button(this));}
1223 var editorActions=(WebInspector.moduleManager.instances(WebInspector.SourcesView.EditorAction));editorActions.forEach(appendButtonForExtension.bind(this));this._statusBarContainerElement.appendChild(this._scriptViewStatusBarItemsContainer);this._statusBarContainerElement.appendChild(this._scriptViewStatusBarTextContainer);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);function handleBeforeUnload(event)
1224 {if(event.returnValue)
1225 return;var unsavedSourceCodes=WebInspector.workspace.unsavedSourceCodes();if(!unsavedSourceCodes.length)
1226 return;event.returnValue=WebInspector.UIString("DevTools have unsaved changes that will be permanently lost.");WebInspector.inspectorView.showPanel("sources");for(var i=0;i<unsavedSourceCodes.length;++i)
1227 WebInspector.panels.sources.showUISourceCode(unsavedSourceCodes[i]);}
1228 window.addEventListener("beforeunload",handleBeforeUnload,true);this._shortcuts={};this.element.addEventListener("keydown",this._handleKeyDown.bind(this),false);}
1229 WebInspector.SourcesView.Events={EditorClosed:"EditorClosed",EditorSelected:"EditorSelected",}
1230 WebInspector.SourcesView.prototype={registerShortcuts:function(registerShortcutDelegate)
1231 {function registerShortcut(shortcuts,handler)
1232 {registerShortcutDelegate(shortcuts,handler);this._registerShortcuts(shortcuts,handler);}
1233 registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToPreviousLocation,this._onJumpToPreviousLocation.bind(this));registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.JumpToNextLocation,this._onJumpToNextLocation.bind(this));registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab,this._onCloseEditorTab.bind(this));registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToLine,this._showGoToLineDialog.bind(this));registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToMember,this._showOutlineDialog.bind(this));registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint,this._toggleBreakpoint.bind(this));registerShortcut.call(this,WebInspector.ShortcutsScreen.SourcesPanelShortcuts.Save,this._save.bind(this));},_registerShortcuts:function(keys,handler)
1234 {for(var i=0;i<keys.length;++i)
1235 this._shortcuts[keys[i].key]=handler;},_handleKeyDown:function(event)
1236 {var shortcutKey=WebInspector.KeyboardShortcut.makeKeyFromEvent(event);var handler=this._shortcuts[shortcutKey];if(handler&&handler())
1237 event.consume(true);},statusBarContainerElement:function()
1238 {return this._statusBarContainerElement;},defaultFocusedElement:function()
1239 {return this._editorContainer.view.defaultFocusedElement();},searchableView:function()
1240 {return this._searchableView;},visibleView:function()
1241 {return this._editorContainer.visibleView;},currentSourceFrame:function()
1242 {var view=this.visibleView();if(!(view instanceof WebInspector.SourceFrame))
1243 return null;return(view);},currentUISourceCode:function()
1244 {return this._currentUISourceCode;},_onCloseEditorTab:function(event)
1245 {var uiSourceCode=this.currentUISourceCode();if(!uiSourceCode)
1246 return false;this._editorContainer.closeFile(uiSourceCode);return true;},_onJumpToPreviousLocation:function(event)
1247 {this._historyManager.rollback();return true;},_onJumpToNextLocation:function(event)
1248 {this._historyManager.rollover();return true;},_uiSourceCodeAdded:function(event)
1249 {var uiSourceCode=(event.data);this._addUISourceCode(uiSourceCode);},_addUISourceCode:function(uiSourceCode)
1250 {if(uiSourceCode.project().isServiceProject())
1251 return;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)
1252 {var uiSourceCode=(event.data);this._removeUISourceCodes([uiSourceCode]);},_removeUISourceCodes:function(uiSourceCodes)
1253 {for(var i=0;i<uiSourceCodes.length;++i){this._removeSourceFrame(uiSourceCodes[i]);this._historyManager.removeHistoryForSourceCode(uiSourceCodes[i]);}
1254 this._editorContainer.removeUISourceCodes(uiSourceCodes);},_projectWillReset:function(event)
1255 {var project=event.data;var uiSourceCodes=project.uiSourceCodes();this._removeUISourceCodes(uiSourceCodes);if(project.type()===WebInspector.projectTypes.Network)
1256 this._editorContainer.reset();},_updateScriptViewStatusBarItems:function()
1257 {this._scriptViewStatusBarItemsContainer.removeChildren();this._scriptViewStatusBarTextContainer.removeChildren();var sourceFrame=this.currentSourceFrame();if(!sourceFrame)
1258 return;var statusBarItems=sourceFrame.statusBarItems()||[];for(var i=0;i<statusBarItems.length;++i)
1259 this._scriptViewStatusBarItemsContainer.appendChild(statusBarItems[i]);var statusBarText=sourceFrame.statusBarText();if(statusBarText)
1260 this._scriptViewStatusBarTextContainer.appendChild(statusBarText);},showSourceLocation:function(uiSourceCode,lineNumber,columnNumber,omitFocus,omitHighlight)
1261 {this._historyManager.updateCurrentState();var sourceFrame=this._showFile(uiSourceCode);if(typeof lineNumber==="number")
1262 sourceFrame.revealPosition(lineNumber,columnNumber,!omitHighlight);this._historyManager.pushNewState();if(!omitFocus)
1263 sourceFrame.focus();WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.OpenSourceLink,url:uiSourceCode.originURL(),lineNumber:lineNumber});},_showFile:function(uiSourceCode)
1264 {var sourceFrame=this._getOrCreateSourceFrame(uiSourceCode);if(this._currentUISourceCode===uiSourceCode)
1265 return sourceFrame;this._currentUISourceCode=uiSourceCode;this._editorContainer.showFile(uiSourceCode);this._updateScriptViewStatusBarItems();return sourceFrame;},_createSourceFrame:function(uiSourceCode)
1266 {var sourceFrame;switch(uiSourceCode.contentType()){case WebInspector.resourceTypes.Script:sourceFrame=new WebInspector.JavaScriptSourceFrame(this._sourcesPanel,uiSourceCode);break;case WebInspector.resourceTypes.Document:sourceFrame=new WebInspector.JavaScriptSourceFrame(this._sourcesPanel,uiSourceCode);break;case WebInspector.resourceTypes.Stylesheet:sourceFrame=new WebInspector.CSSSourceFrame(uiSourceCode);break;default:sourceFrame=new WebInspector.UISourceCodeFrame(uiSourceCode);break;}
1267 sourceFrame.setHighlighterType(uiSourceCode.highlighterType());this._sourceFramesByUISourceCode.put(uiSourceCode,sourceFrame);this._historyManager.trackSourceFrameCursorJumps(sourceFrame);return sourceFrame;},_getOrCreateSourceFrame:function(uiSourceCode)
1268 {return this._sourceFramesByUISourceCode.get(uiSourceCode)||this._createSourceFrame(uiSourceCode);},_sourceFrameMatchesUISourceCode:function(sourceFrame,uiSourceCode)
1269 {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)
1270 {var oldSourceFrame=this._sourceFramesByUISourceCode.get(uiSourceCode);if(!oldSourceFrame)
1271 return;if(this._sourceFrameMatchesUISourceCode(oldSourceFrame,uiSourceCode)){oldSourceFrame.setHighlighterType(uiSourceCode.highlighterType());}else{this._editorContainer.removeUISourceCode(uiSourceCode);this._removeSourceFrame(uiSourceCode);}},viewForFile:function(uiSourceCode)
1272 {return this._getOrCreateSourceFrame(uiSourceCode);},_removeSourceFrame:function(uiSourceCode)
1273 {var sourceFrame=this._sourceFramesByUISourceCode.get(uiSourceCode);if(!sourceFrame)
1274 return;this._sourceFramesByUISourceCode.remove(uiSourceCode);sourceFrame.dispose();},clearCurrentExecutionLine:function()
1275 {if(this._executionSourceFrame)
1276 this._executionSourceFrame.clearExecutionLine();delete this._executionSourceFrame;},setExecutionLine:function(uiLocation)
1277 {var sourceFrame=this._getOrCreateSourceFrame(uiLocation.uiSourceCode);sourceFrame.setExecutionLine(uiLocation.lineNumber);this._executionSourceFrame=sourceFrame;},_editorClosed:function(event)
1278 {var uiSourceCode=(event.data);this._historyManager.removeHistoryForSourceCode(uiSourceCode);var wasSelected=false;if(this._currentUISourceCode===uiSourceCode){delete this._currentUISourceCode;wasSelected=true;}
1279 this._updateScriptViewStatusBarItems();this._searchableView.resetSearch();var data={};data.uiSourceCode=uiSourceCode;data.wasSelected=wasSelected;this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorClosed,data);},_editorSelected:function(event)
1280 {var uiSourceCode=(event.data.currentFile);var shouldUseHistoryManager=uiSourceCode!==this._currentUISourceCode&&event.data.userGesture;if(shouldUseHistoryManager)
1281 this._historyManager.updateCurrentState();var sourceFrame=this._showFile(uiSourceCode);if(shouldUseHistoryManager)
1282 this._historyManager.pushNewState();this._searchableView.setReplaceable(!!sourceFrame&&sourceFrame.canEditSource());this._searchableView.resetSearch();this.dispatchEventToListeners(WebInspector.SourcesView.Events.EditorSelected,uiSourceCode);},sourceRenamed:function(uiSourceCode)
1283 {this._recreateSourceFrameIfNeeded(uiSourceCode);},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);var sourceFrame=this.currentSourceFrame();if(!sourceFrame)
1287 return;this._searchView=sourceFrame;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.currentSourceFrame()){this.performSearch(this._searchQuery,true);return;}
1297 this._searchView.jumpToNextSearchResult();},jumpToPreviousSearchResult:function()
1298 {if(!this._searchView)
1299 return;if(this._searchView!==this.currentSourceFrame()){this.performSearch(this._searchQuery,true);if(this._searchView)
1300 this._searchView.jumpToLastSearchResult();return;}
1301 this._searchView.jumpToPreviousSearchResult();},replaceSelectionWith:function(text)
1302 {var sourceFrame=this.currentSourceFrame();if(!sourceFrame){console.assert(sourceFrame);return;}
1303 sourceFrame.replaceSelectionWith(text);},replaceAllWith:function(query,text)
1304 {var sourceFrame=this.currentSourceFrame();if(!sourceFrame){console.assert(sourceFrame);return;}
1305 sourceFrame.replaceAllWith(query,text);},_showOutlineDialog:function(event)
1306 {var uiSourceCode=this._editorContainer.currentFile();if(!uiSourceCode)
1307 return false;switch(uiSourceCode.contentType()){case WebInspector.resourceTypes.Document:case WebInspector.resourceTypes.Script:WebInspector.JavaScriptOutlineDialog.show(this,uiSourceCode,this.showSourceLocation.bind(this,uiSourceCode));return true;case WebInspector.resourceTypes.Stylesheet:WebInspector.StyleSheetOutlineDialog.show(this,uiSourceCode,this.showSourceLocation.bind(this,uiSourceCode));return true;}
1308 return false;},showOpenResourceDialog:function(query)
1309 {var uiSourceCodes=this._editorContainer.historyUISourceCodes();var defaultScores=new Map();for(var i=1;i<uiSourceCodes.length;++i)
1310 defaultScores.put(uiSourceCodes[i],uiSourceCodes.length-i);WebInspector.OpenResourceDialog.show(this,this.element,query,defaultScores);},_showGoToLineDialog:function(event)
1311 {if(this._currentUISourceCode)
1312 this.showOpenResourceDialog(":");return true;},_save:function()
1313 {var sourceFrame=this.currentSourceFrame();if(!sourceFrame)
1314 return true;if(!(sourceFrame instanceof WebInspector.UISourceCodeFrame))
1315 return true;var uiSourceCodeFrame=(sourceFrame);uiSourceCodeFrame.commitEditing();return true;},_toggleBreakpoint:function()
1316 {var sourceFrame=this.currentSourceFrame();if(!sourceFrame)
1317 return false;if(sourceFrame instanceof WebInspector.JavaScriptSourceFrame){var javaScriptSourceFrame=(sourceFrame);javaScriptSourceFrame.toggleBreakpointOnCurrentLine();return true;}
1318 return false;},toggleBreakpointsActiveState:function(active)
1319 {this._editorContainer.view.element.classList.toggle("breakpoints-deactivated",!active);},__proto__:WebInspector.VBox.prototype}
1320 WebInspector.SourcesView.EditorAction=function()
1321 {}
1322 WebInspector.SourcesView.EditorAction.prototype={button:function(sourcesView){}};WebInspector.SourcesPanel=function(workspaceForTest)
1323 {WebInspector.Panel.call(this,"sources");this.registerRequiredCSS("sourcesPanel.css");this.registerRequiredCSS("textPrompt.css");new WebInspector.UpgradeFileSystemDropTarget(this.element);WebInspector.settings.showEditorInDrawer=WebInspector.settings.createSetting("showEditorInDrawer",true);this._workspace=workspaceForTest||WebInspector.workspace;var helpSection=WebInspector.shortcutsScreen.section(WebInspector.UIString("Sources Panel"));this.debugToolbar=this._createDebugToolbar();this._debugToolbarDrawer=this._createDebugToolbarDrawer();this.threadsToolbar=new WebInspector.ThreadsToolbar();const initialDebugSidebarWidth=225;this._splitView=new WebInspector.SplitView(true,true,"sourcesPanelSplitViewState",initialDebugSidebarWidth);this._splitView.enableShowModeSaving();this._splitView.show(this.element);const initialNavigatorWidth=225;this.editorView=new WebInspector.SplitView(true,false,"sourcesPanelNavigatorSplitViewState",initialNavigatorWidth);this.editorView.enableShowModeSaving();this.editorView.element.id="scripts-editor-split-view";this.editorView.element.tabIndex=0;this.editorView.show(this._splitView.mainElement());this._navigator=new WebInspector.SourcesNavigator(this._workspace);this._navigator.view.setMinimumSize(Preferences.minSidebarWidth,25);this._navigator.view.show(this.editorView.sidebarElement());this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceSelected,this._sourceSelected,this);this._navigator.addEventListener(WebInspector.SourcesNavigator.Events.SourceRenamed,this._sourceRenamed,this);this._sourcesView=new WebInspector.SourcesView(this._workspace,this);this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorSelected,this._editorSelected.bind(this));this._sourcesView.addEventListener(WebInspector.SourcesView.Events.EditorClosed,this._editorClosed.bind(this));this._sourcesView.registerShortcuts(this.registerShortcuts.bind(this));this._drawerEditorView=new WebInspector.SourcesPanel.DrawerEditorView();this._sourcesView.show(this._drawerEditorView.element);this._debugSidebarResizeWidgetElement=document.createElementWithClass("div","resizer-widget");this._debugSidebarResizeWidgetElement.id="scripts-debug-sidebar-resizer-widget";this._splitView.addEventListener(WebInspector.SplitView.Events.ShowModeChanged,this._updateDebugSidebarResizeWidget,this);this._updateDebugSidebarResizeWidget();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.callstack.registerShortcuts(this.registerShortcuts.bind(this));this.sidebarPanes.scopechain=new WebInspector.ScopeChainSidebarPane();this.sidebarPanes.jsBreakpoints=new WebInspector.JavaScriptBreakpointsSidebarPane(WebInspector.debuggerModel,WebInspector.breakpointManager,this.showUISourceCode.bind(this));this.sidebarPanes.domBreakpoints=WebInspector.domBreakpointsSidebarPane.createProxy(this);this.sidebarPanes.xhrBreakpoints=new WebInspector.XHRBreakpointsSidebarPane();this.sidebarPanes.eventListenerBreakpoints=new WebInspector.EventListenerBreakpointsSidebarPane();if(Capabilities.isMainFrontend)
1324 this.sidebarPanes.workerList=new WebInspector.WorkersSidebarPane();this._extensionSidebarPanes=[];this._installDebuggerSidebarController();WebInspector.dockController.addEventListener(WebInspector.DockController.Events.DockSideChanged,this._dockSideChanged.bind(this));WebInspector.settings.splitVerticallyWhenDockedToRight.addChangeListener(this._dockSideChanged.bind(this));this._dockSideChanged();this._updateDebuggerButtons();this._pauseOnExceptionEnabledChanged();if(WebInspector.debuggerModel.isPaused())
1325 this._showDebuggerPausedDetails();WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionEnabledChanged,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.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared,this._debuggerReset,this);}
1326 WebInspector.SourcesPanel.minToolbarWidth=215;WebInspector.SourcesPanel.prototype={defaultFocusedElement:function()
1327 {return this._sourcesView.defaultFocusedElement()||this._navigator.view.defaultFocusedElement();},get paused()
1328 {return this._paused;},_drawerEditor:function()
1329 {var drawerEditorInstance=WebInspector.moduleManager.instance(WebInspector.DrawerEditor);console.assert(drawerEditorInstance instanceof WebInspector.SourcesPanel.DrawerEditor,"WebInspector.DrawerEditor module instance does not use WebInspector.SourcesPanel.DrawerEditor as an implementation. ");return(drawerEditorInstance);},wasShown:function()
1330 {this._drawerEditor()._panelWasShown();this._sourcesView.show(this.editorView.mainElement());WebInspector.Panel.prototype.wasShown.call(this);},willHide:function()
1331 {WebInspector.Panel.prototype.willHide.call(this);this._drawerEditor()._panelWillHide();this._sourcesView.show(this._drawerEditorView.element);},searchableView:function()
1332 {return this._sourcesView.searchableView();},_consoleCommandEvaluatedInSelectedCallFrame:function(event)
1333 {this.sidebarPanes.scopechain.update(WebInspector.debuggerModel.selectedCallFrame());},_debuggerPaused:function()
1334 {WebInspector.inspectorView.setCurrentPanel(this);this._showDebuggerPausedDetails();},_showDebuggerPausedDetails:function()
1335 {var details=WebInspector.debuggerModel.debuggerPausedDetails();this._paused=true;this._waitingToPause=false;this._updateDebuggerButtons();this.sidebarPanes.callstack.update(details.callFrames,details.asyncStackTrace);function didCreateBreakpointHitStatusMessage(element)
1336 {this.sidebarPanes.callstack.setStatus(element);}
1337 function didGetUILocation(uiLocation)
1338 {var breakpoint=WebInspector.breakpointManager.findBreakpointOnLine(uiLocation.uiSourceCode,uiLocation.lineNumber);if(!breakpoint)
1339 return;this.sidebarPanes.jsBreakpoints.highlightBreakpoint(breakpoint);this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a JavaScript breakpoint."));}
1340 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)
1341 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.",details.auxData.description));else if(details.reason===WebInspector.DebuggerModel.BreakReason.Assert)
1342 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));else if(details.reason===WebInspector.DebuggerModel.BreakReason.CSPViolation)
1343 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)
1344 this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a debugged function"));else{if(details.callFrames.length)
1345 details.callFrames[0].createLiveLocation(didGetUILocation.bind(this));else
1346 console.warn("ScriptsPanel paused, but callFrames.length is zero.");}
1347 this._splitView.showBoth(true);this._toggleDebuggerSidebarButton.setEnabled(false);window.focus();InspectorFrontendHost.bringToFront();},_debuggerResumed:function()
1348 {this._paused=false;this._waitingToPause=false;this._clearInterface();this._toggleDebuggerSidebarButton.setEnabled(true);},_debuggerWasEnabled:function()
1349 {this._updateDebuggerButtons();},_debuggerWasDisabled:function()
1350 {this._debuggerReset();},_debuggerReset:function()
1351 {this._debuggerResumed();this.sidebarPanes.watchExpressions.reset();delete this._skipExecutionLineRevealing;},get visibleView()
1352 {return this._sourcesView.visibleView();},showUISourceCode:function(uiSourceCode,lineNumber,columnNumber,forceShowInPanel)
1353 {this._showEditor(forceShowInPanel);this._sourcesView.showSourceLocation(uiSourceCode,lineNumber,columnNumber);},_showEditor:function(forceShowInPanel)
1354 {if(this._sourcesView.isShowing())
1355 return;if(this._shouldShowEditorInDrawer()&&!forceShowInPanel)
1356 this._drawerEditor()._show();else
1357 WebInspector.inspectorView.showPanel("sources");},showUILocation:function(uiLocation,forceShowInPanel)
1358 {this.showUISourceCode(uiLocation.uiSourceCode,uiLocation.lineNumber,uiLocation.columnNumber,forceShowInPanel);},_shouldShowEditorInDrawer:function()
1359 {return WebInspector.experimentsSettings.showEditorInDrawer.isEnabled()&&WebInspector.settings.showEditorInDrawer.get()&&WebInspector.inspectorView.isDrawerEditorShown();},_revealInNavigator:function(uiSourceCode)
1360 {this._navigator.revealUISourceCode(uiSourceCode);},_executionLineChanged:function(uiLocation)
1361 {this._sourcesView.clearCurrentExecutionLine();this._sourcesView.setExecutionLine(uiLocation);if(this._skipExecutionLineRevealing)
1362 return;this._skipExecutionLineRevealing=true;this._sourcesView.showSourceLocation(uiLocation.uiSourceCode,uiLocation.lineNumber,0,undefined,true);},_callFrameSelected:function(event)
1363 {var callFrame=event.data;if(!callFrame)
1364 return;this.sidebarPanes.scopechain.update(callFrame);this.sidebarPanes.watchExpressions.refreshExpressions();this.sidebarPanes.callstack.setSelectedCallFrame(callFrame);callFrame.createLiveLocation(this._executionLineChanged.bind(this));},_sourceSelected:function(event)
1365 {var uiSourceCode=(event.data.uiSourceCode);this._sourcesView.showSourceLocation(uiSourceCode,undefined,undefined,!event.data.focusSource)},_sourceRenamed:function(event)
1366 {var uiSourceCode=(event.data);this._sourcesView.sourceRenamed(uiSourceCode);},_pauseOnExceptionEnabledChanged:function()
1367 {var enabled=WebInspector.settings.pauseOnExceptionEnabled.get();this._pauseOnExceptionButton.toggled=enabled;this._pauseOnExceptionButton.title=WebInspector.UIString(enabled?"Don't pause on exceptions.":"Pause on exceptions.");this._debugToolbarDrawer.classList.toggle("expanded",enabled);},_updateDebuggerButtons:function()
1368 {if(this._paused){this._updateButtonTitle(this._pauseButton,WebInspector.UIString("Resume script execution (%s)."))
1369 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)."))
1370 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()
1371 {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._sourcesView.clearCurrentExecutionLine();this._updateDebuggerButtons();},_togglePauseOnExceptions:function()
1372 {WebInspector.settings.pauseOnExceptionEnabled.set(!this._pauseOnExceptionButton.toggled);},_runSnippet:function()
1373 {var uiSourceCode=this._sourcesView.currentUISourceCode();if(uiSourceCode.project().type()!==WebInspector.projectTypes.Snippets)
1374 return false;WebInspector.scriptSnippetModel.evaluateScriptSnippet(uiSourceCode);return true;},_editorSelected:function(event)
1375 {var uiSourceCode=(event.data);this._editorChanged(uiSourceCode);},_editorClosed:function(event)
1376 {var wasSelected=(event.data.wasSelected);if(wasSelected)
1377 this._editorChanged(null);},_editorChanged:function(uiSourceCode)
1378 {var isSnippet=uiSourceCode&&uiSourceCode.project().type()===WebInspector.projectTypes.Snippets;this._runSnippetButton.element.classList.toggle("hidden",!isSnippet);},_togglePause:function()
1379 {if(this._paused){delete this._skipExecutionLineRevealing;this._paused=false;this._waitingToPause=false;WebInspector.debuggerModel.resume();}else{this._waitingToPause=true;WebInspector.debuggerModel.skipAllPauses(false);DebuggerAgent.pause();}
1380 this._clearInterface();return true;},_longResume:function()
1381 {if(!this._paused)
1382 return true;this._paused=false;this._waitingToPause=false;WebInspector.debuggerModel.skipAllPausesUntilReloadOrTimeout(500);WebInspector.debuggerModel.resume();this._clearInterface();return true;},_stepOverClicked:function()
1383 {if(!this._paused)
1384 return true;delete this._skipExecutionLineRevealing;this._paused=false;this._clearInterface();WebInspector.debuggerModel.stepOver();return true;},_stepIntoClicked:function()
1385 {if(!this._paused)
1386 return true;delete this._skipExecutionLineRevealing;this._paused=false;this._clearInterface();WebInspector.debuggerModel.stepInto();return true;},_stepOutClicked:function()
1387 {if(!this._paused)
1388 return true;delete this._skipExecutionLineRevealing;this._paused=false;this._clearInterface();WebInspector.debuggerModel.stepOut();return true;},_callFrameSelectedInSidebar:function(event)
1389 {var callFrame=(event.data);delete this._skipExecutionLineRevealing;WebInspector.debuggerModel.setSelectedCallFrame(callFrame);},_callFrameRestartedInSidebar:function()
1390 {delete this._skipExecutionLineRevealing;},continueToLocation:function(rawLocation)
1391 {if(!this._paused)
1392 return;delete this._skipExecutionLineRevealing;this._paused=false;this._clearInterface();WebInspector.debuggerModel.continueToLocation(rawLocation);},_toggleBreakpointsClicked:function(event)
1393 {WebInspector.debuggerModel.setBreakpointsActive(!WebInspector.debuggerModel.breakpointsActive());},_breakpointsActiveStateChanged:function(event)
1394 {var active=event.data;this._toggleBreakpointsButton.toggled=!active;this.sidebarPanes.jsBreakpoints.listElement.classList.toggle("breakpoints-list-deactivated",!active);this._sourcesView.toggleBreakpointsActiveState(active);if(active)
1395 this._toggleBreakpointsButton.title=WebInspector.UIString("Deactivate breakpoints.");else
1396 this._toggleBreakpointsButton.title=WebInspector.UIString("Activate breakpoints.");},_createDebugToolbar:function()
1397 {var debugToolbar=document.createElement("div");debugToolbar.className="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);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");this._pauseOnExceptionButton.addEventListener("click",this._togglePauseOnExceptions,this);debugToolbar.appendChild(this._pauseOnExceptionButton.element);return debugToolbar;},_createDebugToolbarDrawer:function()
1398 {var debugToolbarDrawer=document.createElement("div");debugToolbarDrawer.className="scripts-debug-toolbar-drawer";var label=WebInspector.UIString("Pause On Caught Exceptions");var setting=WebInspector.settings.pauseOnCaughtException;debugToolbarDrawer.appendChild(WebInspector.SettingsUI.createSettingCheckbox(label,setting,true));return debugToolbarDrawer;},_updateButtonTitle:function(button,buttonTitle)
1399 {var hasShortcuts=button.shortcuts&&button.shortcuts.length;if(hasShortcuts)
1400 button.title=String.vsprintf(buttonTitle,[button.shortcuts[0].name]);else
1401 button.title=buttonTitle;},_createButtonAndRegisterShortcuts:function(buttonId,buttonTitle,handler,shortcuts)
1402 {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;},addToWatch:function(expression)
1403 {this.sidebarPanes.watchExpressions.addExpression(expression);},_installDebuggerSidebarController:function()
1404 {this._toggleNavigatorSidebarButton=this.editorView.createShowHideSidebarButton("navigator","scripts-navigator-show-hide-button");this.editorView.mainElement().appendChild(this._toggleNavigatorSidebarButton.element);this._toggleDebuggerSidebarButton=this._splitView.createShowHideSidebarButton("debugger","scripts-debugger-show-hide-button");this._splitView.mainElement().appendChild(this._toggleDebuggerSidebarButton.element);this._splitView.mainElement().appendChild(this._debugSidebarResizeWidgetElement);},_updateDebugSidebarResizeWidget:function()
1405 {this._debugSidebarResizeWidgetElement.classList.toggle("hidden",this._splitView.showMode()!==WebInspector.SplitView.ShowMode.Both);},_showLocalHistory:function(uiSourceCode)
1406 {WebInspector.RevisionHistoryView.showHistory(uiSourceCode);},appendApplicableItems:function(event,contextMenu,target)
1407 {this._appendUISourceCodeItems(event,contextMenu,target);this._appendRemoteObjectItems(contextMenu,target);},_suggestReload:function()
1408 {if(window.confirm(WebInspector.UIString("It is recommended to restart inspector after making these changes. Would you like to restart it?")))
1409 WebInspector.reload();},_mapFileSystemToNetwork:function(uiSourceCode)
1410 {WebInspector.SelectUISourceCodeForProjectTypeDialog.show(uiSourceCode.name(),WebInspector.projectTypes.Network,mapFileSystemToNetwork.bind(this),this.editorView.mainElement())
1411 function mapFileSystemToNetwork(networkUISourceCode)
1412 {this._workspace.addMapping(networkUISourceCode,uiSourceCode,WebInspector.fileSystemWorkspaceProvider);this._suggestReload();}},_removeNetworkMapping:function(uiSourceCode)
1413 {if(confirm(WebInspector.UIString("Are you sure you want to remove network mapping?"))){this._workspace.removeMapping(uiSourceCode);this._suggestReload();}},_mapNetworkToFileSystem:function(networkUISourceCode)
1414 {WebInspector.SelectUISourceCodeForProjectTypeDialog.show(networkUISourceCode.name(),WebInspector.projectTypes.FileSystem,mapNetworkToFileSystem.bind(this),this.editorView.mainElement())
1415 function mapNetworkToFileSystem(uiSourceCode)
1416 {this._workspace.addMapping(networkUISourceCode,uiSourceCode,WebInspector.fileSystemWorkspaceProvider);}},_appendUISourceCodeMappingItems:function(contextMenu,uiSourceCode)
1417 {if(uiSourceCode.project().type()===WebInspector.projectTypes.FileSystem){var hasMappings=!!uiSourceCode.url;if(!hasMappings)
1418 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Map to network resource\u2026":"Map to Network Resource\u2026"),this._mapFileSystemToNetwork.bind(this,uiSourceCode));else
1419 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Remove network mapping":"Remove Network Mapping"),this._removeNetworkMapping.bind(this,uiSourceCode));}
1420 function filterProject(project)
1421 {return project.type()===WebInspector.projectTypes.FileSystem;}
1422 if(uiSourceCode.project().type()===WebInspector.projectTypes.Network){if(!this._workspace.projects().filter(filterProject).length)
1423 return;if(this._workspace.uiSourceCodeForURL(uiSourceCode.url)===uiSourceCode)
1424 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(event,contextMenu,target)
1425 {if(!(target instanceof WebInspector.UISourceCode))
1426 return;var uiSourceCode=(target);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Local modifications\u2026":"Local Modifications\u2026"),this._showLocalHistory.bind(this,uiSourceCode));this._appendUISourceCodeMappingItems(contextMenu,uiSourceCode);if(!event.target.isSelfOrDescendant(this.editorView.sidebarElement())){contextMenu.appendSeparator();contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in navigator":"Reveal in Navigator"),this._handleContextMenuReveal.bind(this,uiSourceCode));}},_handleContextMenuReveal:function(uiSourceCode)
1427 {this.editorView.showBoth();this._revealInNavigator(uiSourceCode);},_appendRemoteObjectItems:function(contextMenu,target)
1428 {if(!(target instanceof WebInspector.RemoteObject))
1429 return;var remoteObject=(target);contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Store as global variable":"Store as Global Variable"),this._saveToTempVariable.bind(this,remoteObject));if(remoteObject.type==="function")
1430 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Show function definition":"Show Function Definition"),this._showFunctionDefinition.bind(this,remoteObject));},_saveToTempVariable:function(remoteObject)
1431 {WebInspector.runtimeModel.evaluate("window","",false,true,false,false,didGetGlobalObject);function didGetGlobalObject(global,wasThrown)
1432 {function remoteFunction(value)
1433 {var prefix="temp";var index=1;while((prefix+index)in this)
1434 ++index;var name=prefix+index;this[name]=value;return name;}
1435 if(wasThrown||!global)
1436 failedToSave(global);else
1437 global.callFunction(remoteFunction,[WebInspector.RemoteObject.toCallArgument(remoteObject)],didSave.bind(null,global));}
1438 function didSave(global,result,wasThrown)
1439 {global.release();if(wasThrown||!result||result.type!=="string")
1440 failedToSave(result);else
1441 WebInspector.console.evaluate(result.value);}
1442 function failedToSave(result)
1443 {var message=WebInspector.UIString("Failed to save to temp variable.");if(result){message+=" "+result.description;result.release();}
1444 WebInspector.console.showErrorMessage(message)}},_showFunctionDefinition:function(remoteObject)
1445 {function didGetFunctionDetails(error,response)
1446 {if(error){console.error(error);return;}
1447 var uiLocation=WebInspector.debuggerModel.rawLocationToUILocation(response.location);if(!uiLocation)
1448 return;this.showUILocation(uiLocation,true);}
1449 DebuggerAgent.getFunctionDetails(remoteObject.objectId,didGetFunctionDetails.bind(this));},showGoToSourceDialog:function()
1450 {this._sourcesView.showOpenResourceDialog();},_dockSideChanged:function()
1451 {var vertically=WebInspector.dockController.isVertical()&&WebInspector.settings.splitVerticallyWhenDockedToRight.get();this._splitVertically(vertically);},_splitVertically:function(vertically)
1452 {if(this.sidebarPaneView&&vertically===!this._splitView.isVertical())
1453 return;if(this.sidebarPaneView)
1454 this.sidebarPaneView.detach();this._splitView.setVertical(!vertically);if(!vertically)
1455 this._splitView.uninstallResizer(this._sourcesView.statusBarContainerElement());else
1456 this._splitView.installResizer(this._sourcesView.statusBarContainerElement());var vbox=new WebInspector.VBox();vbox.element.appendChild(this._debugToolbarDrawer);vbox.element.appendChild(this.debugToolbar);vbox.element.appendChild(this.threadsToolbar.element);vbox.setMinimumSize(WebInspector.SourcesPanel.minToolbarWidth,25);var sidebarPaneStack=new WebInspector.SidebarPaneStack();sidebarPaneStack.element.classList.add("flex-auto");sidebarPaneStack.show(vbox.element);if(!vertically){for(var pane in this.sidebarPanes)
1457 sidebarPaneStack.addPane(this.sidebarPanes[pane]);this._extensionSidebarPanesContainer=sidebarPaneStack;this.sidebarPaneView=vbox;}else{var splitView=new WebInspector.SplitView(true,true,"sourcesPanelDebuggerSidebarSplitViewState",0.5);vbox.show(splitView.mainElement());sidebarPaneStack.addPane(this.sidebarPanes.callstack);sidebarPaneStack.addPane(this.sidebarPanes.jsBreakpoints);sidebarPaneStack.addPane(this.sidebarPanes.domBreakpoints);sidebarPaneStack.addPane(this.sidebarPanes.xhrBreakpoints);sidebarPaneStack.addPane(this.sidebarPanes.eventListenerBreakpoints);if(this.sidebarPanes.workerList)
1458 sidebarPaneStack.addPane(this.sidebarPanes.workerList);var tabbedPane=new WebInspector.SidebarTabbedPane();tabbedPane.show(splitView.sidebarElement());tabbedPane.addPane(this.sidebarPanes.scopechain);tabbedPane.addPane(this.sidebarPanes.watchExpressions);this._extensionSidebarPanesContainer=tabbedPane;this.sidebarPaneView=splitView;}
1459 for(var i=0;i<this._extensionSidebarPanes.length;++i)
1460 this._extensionSidebarPanesContainer.addPane(this._extensionSidebarPanes[i]);this.sidebarPaneView.show(this._splitView.sidebarElement());this.sidebarPanes.scopechain.expand();this.sidebarPanes.jsBreakpoints.expand();this.sidebarPanes.callstack.expand();if(WebInspector.settings.watchExpressions.get().length>0)
1461 this.sidebarPanes.watchExpressions.expand();},addExtensionSidebarPane:function(id,pane)
1462 {this._extensionSidebarPanes.push(pane);this._extensionSidebarPanesContainer.addPane(pane);this.setHideOnDetach();},sourcesView:function()
1463 {return this._sourcesView;},__proto__:WebInspector.Panel.prototype}
1464 WebInspector.UpgradeFileSystemDropTarget=function(element)
1465 {element.addEventListener("dragenter",this._onDragEnter.bind(this),true);element.addEventListener("dragover",this._onDragOver.bind(this),true);this._element=element;}
1466 WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType="Files";WebInspector.UpgradeFileSystemDropTarget.prototype={_onDragEnter:function(event)
1467 {if(event.dataTransfer.types.indexOf(WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType)===-1)
1468 return;event.consume(true);},_onDragOver:function(event)
1469 {if(event.dataTransfer.types.indexOf(WebInspector.UpgradeFileSystemDropTarget.dragAndDropFilesType)===-1)
1470 return;event.dataTransfer.dropEffect="copy";event.consume(true);if(this._dragMaskElement)
1471 return;this._dragMaskElement=this._element.createChild("div","fill drag-mask");this._dragMaskElement.createChild("div","fill drag-mask-inner").textContent=WebInspector.UIString("Drop workspace folder here");this._dragMaskElement.addEventListener("drop",this._onDrop.bind(this),true);this._dragMaskElement.addEventListener("dragleave",this._onDragLeave.bind(this),true);},_onDrop:function(event)
1472 {event.consume(true);this._removeMask();var items=(event.dataTransfer.items);if(!items.length)
1473 return;var entry=items[0].webkitGetAsEntry();if(!entry.isDirectory)
1474 return;InspectorFrontendHost.upgradeDraggedFileSystemPermissions(entry.filesystem);},_onDragLeave:function(event)
1475 {event.consume(true);this._removeMask();},_removeMask:function()
1476 {this._dragMaskElement.remove();delete this._dragMaskElement;}}
1477 WebInspector.SourcesPanel.DrawerEditor=function()
1478 {this._panel=WebInspector.inspectorView.panel("sources");}
1479 WebInspector.SourcesPanel.DrawerEditor.prototype={view:function()
1480 {return this._panel._drawerEditorView;},installedIntoDrawer:function()
1481 {if(this._panel.isShowing())
1482 this._panelWasShown();else
1483 this._panelWillHide();},_panelWasShown:function()
1484 {WebInspector.inspectorView.setDrawerEditorAvailable(false);WebInspector.inspectorView.hideDrawerEditor();},_panelWillHide:function()
1485 {WebInspector.inspectorView.setDrawerEditorAvailable(true);if(WebInspector.inspectorView.isDrawerEditorShown())
1486 WebInspector.inspectorView.showDrawerEditor();},_show:function()
1487 {WebInspector.inspectorView.showDrawerEditor();},}
1488 WebInspector.SourcesPanel.DrawerEditorView=function()
1489 {WebInspector.VBox.call(this);this.element.id="drawer-editor-view";}
1490 WebInspector.SourcesPanel.DrawerEditorView.prototype={__proto__:WebInspector.VBox.prototype}
1491 WebInspector.SourcesPanel.ContextMenuProvider=function()
1492 {}
1493 WebInspector.SourcesPanel.ContextMenuProvider.prototype={appendApplicableItems:function(event,contextMenu,target)
1494 {WebInspector.inspectorView.panel("sources").appendApplicableItems(event,contextMenu,target);}}
1495 WebInspector.SourcesPanel.UILocationRevealer=function()
1496 {}
1497 WebInspector.SourcesPanel.UILocationRevealer.prototype={reveal:function(uiLocation)
1498 {if(uiLocation instanceof WebInspector.UILocation)
1499 (WebInspector.inspectorView.panel("sources")).showUILocation(uiLocation);}}
1500 WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate=function(){}
1501 WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate.prototype={handleAction:function()
1502 {(WebInspector.inspectorView.showPanel("sources")).showGoToSourceDialog();return true;}}