Index: chrome_linux64/resources/inspector/ScriptsPanel.js |
=================================================================== |
--- chrome_linux64/resources/inspector/ScriptsPanel.js (revision 197568) |
+++ chrome_linux64/resources/inspector/ScriptsPanel.js (working copy) |
@@ -824,6 +824,7 @@ |
styleElement.textContent = xhr.responseText; |
this._promptElement = this.element.createChild("input", "monospace"); |
+this._promptElement.addEventListener("input", this._onInput.bind(this), false); |
this._promptElement.type = "text"; |
this._promptElement.setAttribute("spellcheck", "false"); |
@@ -1057,9 +1058,16 @@ |
} |
} |
this._viewportControl.refresh(); |
+if (!query) |
+this._selectedIndexInFiltered = 0; |
this._updateSelection(this._selectedIndexInFiltered, false); |
}, |
+_onInput: function(event) |
+{ |
+this._scheduleFilter(); |
+}, |
+ |
_onKeyDown: function(event) |
{ |
var newSelectedIndex = this._selectedIndexInFiltered; |
@@ -1088,8 +1096,6 @@ |
event.consume(true); |
break; |
default: |
-if (event.keyIdentifier !== "Shift" && event.keyIdentifier !== "Ctrl" && event.keyIdentifier !== "Meta" && event.keyIdentifier !== "Left" && event.keyIdentifier !== "Right") |
-this._scheduleFilter(); |
} |
}, |
@@ -1351,7 +1357,7 @@ |
selectItem: function(itemIndex, promptValue) |
{ |
var lineNumberMatch = promptValue.match(/[^:]+\:([\d]*)$/); |
-var lineNumber = lineNumberMatch ? Math.max(parseInt(lineNumberMatch[1], 10) - 1, 0) : 0; |
+var lineNumber = lineNumberMatch ? Math.max(parseInt(lineNumberMatch[1], 10) - 1, 0) : undefined; |
this.uiSourceCodeSelected(this._uiSourceCodes[itemIndex], lineNumber); |
}, |
@@ -1407,13 +1413,15 @@ |
} |
-WebInspector.OpenResourceDialog.show = function(panel, relativeToElement) |
+WebInspector.OpenResourceDialog.show = function(panel, relativeToElement, name) |
{ |
if (WebInspector.Dialog.currentInstance()) |
return; |
var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel)); |
filteredItemSelectionDialog.renderAsTwoRows(); |
+if (name) |
+filteredItemSelectionDialog.setQuery(name); |
WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); |
} |
@@ -1479,6 +1487,7 @@ |
WebInspector.SourceFrame.prototype.willHide.call(this); |
window.removeEventListener("focus", this._boundWindowFocused, false); |
delete this._boundWindowFocused; |
+this._uiSourceCode.removeWorkingCopyGetter(); |
}, |
@@ -1505,17 +1514,22 @@ |
if (!this._uiSourceCode.isDirty()) |
return; |
-this._isCommittingEditing = true; |
+this._muteSourceCodeEvents = true; |
this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this)); |
-delete this._isCommittingEditing; |
+delete this._muteSourceCodeEvents; |
}, |
onTextChanged: function(oldRange, newRange) |
{ |
WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange); |
-this._isSettingWorkingCopy = true; |
-this._uiSourceCode.setWorkingCopy(this._textEditor.text()); |
-delete this._isSettingWorkingCopy; |
+if (this._isSettingContent) |
+return; |
+this._muteSourceCodeEvents = true; |
+if (this._textEditor.isClean()) |
+this._uiSourceCode.resetWorkingCopy(); |
+else |
+this._uiSourceCode.setWorkingCopyGetter(this._textEditor.text.bind(this._textEditor)); |
+delete this._muteSourceCodeEvents; |
}, |
_didEditContent: function(error) |
@@ -1531,33 +1545,38 @@ |
{ |
var content = (event.data.content); |
this._textEditor.setReadOnly(this._uiSourceCode.formatted()); |
-this.setContent(content, false, this._uiSourceCode.mimeType()); |
+this._innerSetContent(content); |
}, |
_onWorkingCopyChanged: function(event) |
{ |
+if (this._muteSourceCodeEvents) |
+return; |
this._innerSetContent(this._uiSourceCode.workingCopy()); |
+this.onUISourceCodeContentChanged(); |
}, |
_onWorkingCopyCommitted: function(event) |
{ |
+this._textEditor.markClean(); |
+if (this._muteSourceCodeEvents) |
+return; |
this._innerSetContent(this._uiSourceCode.workingCopy()); |
+this.onUISourceCodeContentChanged(); |
}, |
- |
-onUISourceCodeContentChanged: function(content) |
+onUISourceCodeContentChanged: function() |
{ |
-this.setContent(content, false, this._uiSourceCode.mimeType()); |
}, |
_innerSetContent: function(content) |
{ |
-if (this._isSettingWorkingCopy || this._isCommittingEditing) |
-return; |
-this.onUISourceCodeContentChanged(content); |
+this._isSettingContent = true; |
+this.setContent(content, false, this._uiSourceCode.mimeType()); |
+delete this._isSettingContent; |
}, |
populateTextAreaContextMenu: function(contextMenu, lineNumber) |
@@ -1621,11 +1640,10 @@ |
this._popoverHelper.hidePopover(); |
}, |
- |
-onUISourceCodeContentChanged: function(content, contentEncoded, mimeType) |
+onUISourceCodeContentChanged: function() |
{ |
this._removeAllBreakpoints(); |
-WebInspector.UISourceCodeFrame.prototype.onUISourceCodeContentChanged.call(this, content); |
+WebInspector.UISourceCodeFrame.prototype.onUISourceCodeContentChanged.call(this); |
}, |
populateLineGutterContextMenu: function(contextMenu, lineNumber) |
@@ -2278,12 +2296,9 @@ |
WebInspector.View.call(this); |
this.registerRequiredCSS("navigatorView.css"); |
-this._treeSearchBoxElement = document.createElement("div"); |
-this._treeSearchBoxElement.className = "navigator-tree-search-box"; |
-this.element.appendChild(this._treeSearchBoxElement); |
- |
var scriptsTreeElement = document.createElement("ol"); |
-this._scriptsTree = new WebInspector.NavigatorTreeOutline(this._treeSearchBoxElement, scriptsTreeElement); |
+this._scriptsTree = new WebInspector.NavigatorTreeOutline(scriptsTreeElement); |
+this._scriptsTree.childrenListElement.addEventListener("keypress", this._treeKeyPress.bind(this), true); |
var scriptsOutlineElement = document.createElement("div"); |
scriptsOutlineElement.addStyleClass("outline-disclosure"); |
@@ -2306,6 +2321,7 @@ |
WebInspector.NavigatorView.Events = { |
ItemSelected: "ItemSelected", |
+ItemSearchStarted: "ItemSearchStarted", |
FileRenamed: "FileRenamed" |
} |
@@ -2465,6 +2481,11 @@ |
}, |
+handleRename: function(uiSourceCode, callback) |
+{ |
+}, |
+ |
+ |
rename: function(uiSourceCode, callback) |
{ |
var node = this._uiSourceCodeNodes[uiSourceCode.uri()]; |
@@ -2478,7 +2499,6 @@ |
for (var uri in this._uiSourceCodeNodes) |
this._uiSourceCodeNodes[uri].dispose(); |
-this._scriptsTree.stopSearch(); |
this._scriptsTree.removeChildren(); |
this._uiSourceCodeNodes = {}; |
this._rootNode.reset(); |
@@ -2491,21 +2511,28 @@ |
contextMenu.show(); |
}, |
+_treeKeyPress: function(event) |
+{ |
+if (WebInspector.isBeingEdited(this._scriptsTree.childrenListElement)) |
+return; |
+ |
+var searchText = String.fromCharCode(event.charCode); |
+if (searchText.trim() !== searchText) |
+return; |
+this.dispatchEventToListeners(WebInspector.NavigatorView.Events.ItemSearchStarted, searchText); |
+event.consume(true); |
+}, |
+ |
__proto__: WebInspector.View.prototype |
} |
-WebInspector.NavigatorTreeOutline = function(treeSearchBoxElement, element) |
+WebInspector.NavigatorTreeOutline = function(element) |
{ |
TreeOutline.call(this, element); |
this.element = element; |
-this._treeSearchBoxElement = treeSearchBoxElement; |
- |
this.comparator = WebInspector.NavigatorTreeOutline._treeElementsCompare; |
- |
-this.searchable = true; |
-this.searchInputElement = document.createElement("input"); |
} |
WebInspector.NavigatorTreeOutline.Types = { |
@@ -2564,18 +2591,6 @@ |
return result; |
}, |
-searchStarted: function() |
-{ |
-this._treeSearchBoxElement.appendChild(this.searchInputElement); |
-this._treeSearchBoxElement.addStyleClass("visible"); |
-}, |
- |
-searchFinished: function() |
-{ |
-this._treeSearchBoxElement.removeChild(this.searchInputElement); |
-this._treeSearchBoxElement.removeStyleClass("visible"); |
-}, |
- |
__proto__: TreeOutline.prototype |
} |
@@ -2638,12 +2653,6 @@ |
}, |
-matchesSearchText: function(searchText) |
-{ |
-return this.titleText.match(new RegExp("^" + searchText.escapeForRegExp(), "i")); |
-}, |
- |
- |
type: function() |
{ |
return this._type; |
@@ -2724,6 +2733,28 @@ |
} |
}, |
+_shouldRenameOnMouseDown: function() |
+{ |
+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) |
+{ |
+if (!this._shouldRenameOnMouseDown()) { |
+TreeElement.prototype.selectOnMouseDown.call(this, event); |
+return; |
+} |
+setTimeout(rename.bind(this), 300); |
+ |
+function rename() |
+{ |
+if (this._shouldRenameOnMouseDown()) |
+this._navigatorView.handleRename(this._uiSourceCode); |
+} |
+}, |
+ |
_ondragstart: function(event) |
{ |
event.dataTransfer.setData("text/plain", this._warmedUpContent); |
@@ -2759,6 +2790,7 @@ |
_handleContextMenuEvent: function(event) |
{ |
+this.select(); |
this._navigatorView.handleContextMenu(event, this._uiSourceCode); |
}, |
@@ -3587,12 +3619,15 @@ |
this._scriptsView = new WebInspector.NavigatorView(); |
this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this); |
+this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSearchStarted, this._itemSearchStarted, this); |
this._contentScriptsView = new WebInspector.NavigatorView(); |
this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this); |
+this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSearchStarted, this._itemSearchStarted, this); |
this._snippetsView = new WebInspector.SnippetsNavigatorView(); |
this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this); |
+this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSearchStarted, this._itemSearchStarted, this); |
this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.FileRenamed, this._fileRenamed, this); |
this._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Events.SnippetCreationRequested, this._snippetCreationRequested, this); |
this._snippetsView.addEventListener(WebInspector.SnippetsNavigatorView.Events.ItemRenamingRequested, this._itemRenamingRequested, this); |
@@ -3600,7 +3635,6 @@ |
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ScriptsTab, WebInspector.UIString("Sources"), this._scriptsView); |
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab); |
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ContentScriptsTab, WebInspector.UIString("Content scripts"), this._contentScriptsView); |
-if (WebInspector.experimentsSettings.snippetsSupport.isEnabled()) |
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.SnippetsTab, WebInspector.UIString("Snippets"), this._snippetsView); |
} |
@@ -3608,6 +3642,7 @@ |
ScriptSelected: "ScriptSelected", |
SnippetCreationRequested: "SnippetCreationRequested", |
ItemRenamingRequested: "ItemRenamingRequested", |
+ItemSearchStarted: "ItemSearchStarted", |
FileRenamed: "FileRenamed" |
} |
@@ -3668,6 +3703,12 @@ |
}, |
+_itemSearchStarted: function(event) |
+{ |
+this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemSearchStarted, event.data); |
+}, |
+ |
+ |
_fileRenamed: function(event) |
{ |
this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.FileRenamed, event.data); |
@@ -3707,7 +3748,7 @@ |
var contextMenu = new WebInspector.ContextMenu(event); |
if (uiSourceCode) { |
contextMenu.appendItem(WebInspector.UIString("Run"), this._handleEvaluateSnippet.bind(this, uiSourceCode)); |
-contextMenu.appendItem(WebInspector.UIString("Rename"), this._handleRenameSnippet.bind(this, uiSourceCode)); |
+contextMenu.appendItem(WebInspector.UIString("Rename"), this.handleRename.bind(this, uiSourceCode)); |
contextMenu.appendItem(WebInspector.UIString("Remove"), this._handleRemoveSnippet.bind(this, uiSourceCode)); |
contextMenu.appendSeparator(); |
} |
@@ -3724,7 +3765,7 @@ |
}, |
-_handleRenameSnippet: function(uiSourceCode) |
+handleRename: function(uiSourceCode) |
{ |
this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ItemRenamingRequested, uiSourceCode); |
}, |
@@ -3852,53 +3893,6 @@ |
-WebInspector.SnippetJavaScriptSourceFrame = function(scriptsPanel, uiSourceCode) |
-{ |
-WebInspector.JavaScriptSourceFrame.call(this, scriptsPanel, uiSourceCode); |
- |
-this._uiSourceCode = uiSourceCode; |
-this._runButton = new WebInspector.StatusBarButton(WebInspector.UIString("Run"), "evaluate-snippet-status-bar-item"); |
-this._runButton.addEventListener("click", this._runButtonClicked, this); |
-this.textEditor.element.addEventListener("keydown", this._onKeyDown.bind(this), true); |
-this._snippetsShortcuts = {}; |
-var runSnippetShortcutDescriptor = WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Enter, WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta) |
-this._snippetsShortcuts[runSnippetShortcutDescriptor.key] = this._runSnippet.bind(this); |
-} |
- |
-WebInspector.SnippetJavaScriptSourceFrame.prototype = { |
- |
-statusBarItems: function() |
-{ |
-return [this._runButton.element].concat(WebInspector.JavaScriptSourceFrame.prototype.statusBarItems.call(this)); |
-}, |
- |
-_runButtonClicked: function() |
-{ |
-this._runSnippet(); |
-}, |
- |
-_runSnippet: function() |
-{ |
-WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._uiSourceCode); |
-}, |
- |
- |
-_onKeyDown: function(event) |
-{ |
-var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); |
-var handler = this._snippetsShortcuts[shortcutKey]; |
-if (handler) { |
-handler(event); |
-event.handled = true; |
-} |
-}, |
- |
-__proto__: WebInspector.JavaScriptSourceFrame.prototype |
-} |
-; |
- |
- |
- |
WebInspector.StyleSheetOutlineDialog = function(view, uiSourceCode) |
{ |
WebInspector.SelectionDialogContentProvider.call(this); |
@@ -5136,6 +5130,7 @@ |
this._navigatorController = new WebInspector.NavigatorOverlayController(this.editorView, this._navigator.view, this._editorContainer.view); |
this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.ScriptSelected, this._scriptSelected, this); |
+this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.ItemSearchStarted, this._itemSearchStarted, this); |
this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.SnippetCreationRequested, this._snippetCreationRequested, this); |
this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.ItemRenamingRequested, this._itemRenamingRequested, this); |
this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.FileRenamed, this._fileRenamed, this); |
@@ -5453,6 +5448,11 @@ |
this._editorContainer.showFile(uiSourceCode); |
this._updateScriptViewStatusBarItems(); |
+if (this._currentUISourceCode.project().type() === WebInspector.projectTypes.Snippets) |
+this._runSnippetButton.element.removeStyleClass("hidden"); |
+else |
+this._runSnippetButton.element.addStyleClass("hidden"); |
+ |
return sourceFrame; |
}, |
@@ -5462,9 +5462,6 @@ |
var sourceFrame; |
switch (uiSourceCode.contentType()) { |
case WebInspector.resourceTypes.Script: |
-if (uiSourceCode.project().type() === WebInspector.projectTypes.Snippets) |
-sourceFrame = new WebInspector.SnippetJavaScriptSourceFrame(this, uiSourceCode); |
-else |
sourceFrame = new WebInspector.JavaScriptSourceFrame(this, uiSourceCode); |
break; |
case WebInspector.resourceTypes.Document: |
@@ -5564,6 +5561,7 @@ |
var uiSourceCode = (event.data); |
var sourceFrame = this._showFile(uiSourceCode); |
this._navigatorController.hideNavigatorOverlay(); |
+if (!this._navigatorController.isNavigatorPinned()) |
sourceFrame.focus(); |
WebInspector.searchController.resetSearch(); |
}, |
@@ -5573,10 +5571,16 @@ |
var uiSourceCode = (event.data.uiSourceCode); |
var sourceFrame = this._showFile(uiSourceCode); |
this._navigatorController.hideNavigatorOverlay(); |
-if (sourceFrame && event.data.focusSource) |
+if (sourceFrame && (!this._navigatorController.isNavigatorPinned() || event.data.focusSource)) |
sourceFrame.focus(); |
}, |
+_itemSearchStarted: function(event) |
+{ |
+var searchText = (event.data); |
+WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement, searchText); |
+}, |
+ |
_pauseOnExceptionStateChanged: function() |
{ |
var pauseOnExceptionsState = WebInspector.settings.pauseOnExceptionStateString.get(); |
@@ -5654,6 +5658,15 @@ |
}, |
+_runSnippet: function(event) |
+{ |
+if (this._currentUISourceCode.project().type() !== WebInspector.projectTypes.Snippets) |
+return false; |
+WebInspector.scriptSnippetModel.evaluateScriptSnippet(this._currentUISourceCode); |
+return true; |
+}, |
+ |
+ |
_togglePause: function(event) |
{ |
if (this._paused) { |
@@ -5755,6 +5768,12 @@ |
var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta; |
+handler = this._runSnippet.bind(this); |
+this._runSnippetButton = this._createButtonAndRegisterShortcuts("scripts-run-snippet", "", handler, WebInspector.ScriptsPanelDescriptor.ShortcutKeys.RunSnippet); |
+debugToolbar.appendChild(this._runSnippetButton.element); |
+this._runSnippetButton.element.addStyleClass("hidden"); |
+ |
+ |
handler = this._togglePause.bind(this); |
this._pauseButton = this._createButtonAndRegisterShortcuts("scripts-pause", "", handler, WebInspector.ScriptsPanelDescriptor.ShortcutKeys.PauseContinue); |
debugToolbar.appendChild(this._pauseButton.element); |