Commit f3ead5f2 authored by vsevik@chromium.org's avatar vsevik@chromium.org

DevTools: Use open resource dialog for go to line feature in sources panel.

R=lushnikov@chromium.org, lushnikov, pfeldman

Review URL: https://codereview.chromium.org/202043002

git-svn-id: svn://svn.chromium.org/blink/trunk@169530 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 010086a3
......@@ -244,7 +244,7 @@ function test()
panel.showUISourceCode(uiSourceCode, jumps[i]);
dumpSelection(panel.visibleView.textEditor, "jump to line " + jumps[i]);
}
panel.highlightPosition(40, 10);
panel.showUISourceCode(uiSourceCode, 40, 10);
dumpSelection(panel.visibleView.textEditor, "highlight line 40");
for (var i = 0; i < jumps.length + 1; ++i) {
rollback();
......
......@@ -63,8 +63,6 @@ WebInspector.FilteredItemSelectionDialog = function(delegate)
this._delegate = delegate;
this._delegate.setRefreshCallback(this._itemsLoaded.bind(this));
this._itemsLoaded();
this._shouldShowMatchingItems = true;
}
WebInspector.FilteredItemSelectionDialog.prototype = {
......@@ -252,17 +250,25 @@ WebInspector.FilteredItemSelectionDialog.prototype = {
}
},
/**
* @return {boolean}
*/
_shouldShowMatchingItems: function()
{
return this._delegate.shouldShowMatchingItems(this._promptElement.value);
},
_onInput: function(event)
{
this._shouldShowMatchingItems = this._delegate.shouldShowMatchingItems(this._promptElement.value);
this._updateShowMatchingItems();
this._scheduleFilter();
},
_updateShowMatchingItems: function()
{
this._itemElementsContainer.classList.toggle("hidden", !this._shouldShowMatchingItems);
this.element.style.height = this._shouldShowMatchingItems ? this._dialogHeight + "px" : "auto";
var shouldShowMatchingItems = this._shouldShowMatchingItems();
this._itemElementsContainer.classList.toggle("hidden", !shouldShowMatchingItems);
this.element.style.height = shouldShowMatchingItems ? this._dialogHeight + "px" : "auto";
},
_onKeyDown: function(event)
......@@ -811,18 +817,18 @@ WebInspector.OpenResourceDialog.prototype = {
/**
* @param {!WebInspector.SourcesPanel} panel
* @param {!Element} relativeToElement
* @param {string=} name
* @param {string=} query
* @param {!Map.<!WebInspector.UISourceCode, number>=} defaultScores
*/
WebInspector.OpenResourceDialog.show = function(panel, relativeToElement, name, defaultScores)
WebInspector.OpenResourceDialog.show = function(panel, relativeToElement, query, defaultScores)
{
if (WebInspector.Dialog.currentInstance())
return;
var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel, defaultScores));
filteredItemSelectionDialog.renderAsTwoRows();
if (name)
filteredItemSelectionDialog.setQuery(name);
if (query)
filteredItemSelectionDialog.setQuery(query);
WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
}
......
......@@ -81,8 +81,6 @@ WebInspector.GoToLineDialog._show = function(viewGetter, event)
*/
WebInspector.GoToLineDialog.createShortcut = function()
{
var isMac = WebInspector.isMac();
var shortcut;
return WebInspector.KeyboardShortcut.makeDescriptor("g", WebInspector.KeyboardShortcut.Modifiers.Ctrl);
}
......
......@@ -259,6 +259,7 @@ WebInspector.ShortcutsScreen.registerShortcuts = function()
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.EvaluateSelectionInConsole, WebInspector.UIString("Evaluate selection in console"));
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.AddSelectionToWatch, WebInspector.UIString("Add selection to watch"));
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, WebInspector.UIString("Go to member"));
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToLine, WebInspector.UIString("Go to line"));
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, WebInspector.UIString("Toggle breakpoint"));
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleComment, WebInspector.UIString("Toggle comment"));
section.addAlternateKeys(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab, WebInspector.UIString("Close editor tab"));
......@@ -406,6 +407,10 @@ WebInspector.ShortcutsScreen.SourcesPanelShortcuts = {
WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift)
],
GoToLine: [
WebInspector.KeyboardShortcut.makeDescriptor("g", WebInspector.KeyboardShortcut.Modifiers.Ctrl)
],
ToggleBreakpoint: [
WebInspector.KeyboardShortcut.makeDescriptor("b", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta)
],
......
......@@ -66,16 +66,6 @@ WebInspector.SourcesPanel = function(workspaceForTest)
this._workspace = workspaceForTest || WebInspector.workspace;
/**
* @return {!WebInspector.View}
* @this {WebInspector.SourcesPanel}
*/
function viewGetter()
{
return this;
}
WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString("Sources Panel"));
this.debugToolbar = this._createDebugToolbar();
this._debugToolbarDrawer = this._createDebugToolbarDrawer();
......@@ -149,6 +139,7 @@ WebInspector.SourcesPanel = function(workspaceForTest)
this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.CloseEditorTab, this._onCloseEditorTab.bind(this));
this.sidebarPanes.callstack.registerShortcuts(this.registerShortcuts.bind(this));
this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToLine, this._showGoToLineDialog.bind(this));
this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.GoToMember, this._showOutlineDialog.bind(this));
this.registerShortcuts(WebInspector.ShortcutsScreen.SourcesPanelShortcuts.ToggleBreakpoint, this._toggleBreakpoint.bind(this));
......@@ -1242,10 +1233,10 @@ WebInspector.SourcesPanel.prototype = {
switch (uiSourceCode.contentType()) {
case WebInspector.resourceTypes.Document:
case WebInspector.resourceTypes.Script:
WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSourceCode, this.highlightPosition.bind(this));
WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSourceCode, this.showUISourceCode.bind(this, uiSourceCode));
return true;
case WebInspector.resourceTypes.Stylesheet:
WebInspector.StyleSheetOutlineDialog.show(this.visibleView, uiSourceCode, this.highlightPosition.bind(this));
WebInspector.StyleSheetOutlineDialog.show(this.visibleView, uiSourceCode, this.showUISourceCode.bind(this, uiSourceCode));
return true;
}
return false;
......@@ -1438,14 +1429,32 @@ WebInspector.SourcesPanel.prototype = {
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Show function definition" : "Show Function Definition"), revealFunction.bind(this));
},
showGoToSourceDialog: function()
/**
* @param {string=} query
*/
_showOpenResourceDialog: function(query)
{
var uiSourceCodes = this._editorContainer.historyUISourceCodes();
/** @type {!Map.<!WebInspector.UISourceCode, number>} */
var defaultScores = new Map();
for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element
defaultScores.put(uiSourceCodes[i], uiSourceCodes.length - i);
WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement(), undefined, defaultScores);
WebInspector.OpenResourceDialog.show(this, this.editorView.mainElement(), query, defaultScores);
},
/**
* @param {?Event=} event
* @return {boolean}
*/
_showGoToLineDialog: function(event)
{
this._showOpenResourceDialog(":");
return true;
},
showGoToSourceDialog: function()
{
this._showOpenResourceDialog();
},
_dockSideChanged: function()
......@@ -1523,28 +1532,6 @@ WebInspector.SourcesPanel.prototype = {
this.sidebarPanes.watchExpressions.expand();
},
/**
* @return {boolean}
*/
canHighlightPosition: function()
{
return !!this.currentSourceFrame();
},
/**
* @param {number} line
* @param {number=} column
*/
highlightPosition: function(line, column)
{
var sourceFrame = this.currentSourceFrame();
if (!sourceFrame)
return;
this._historyManager.updateCurrentState();
sourceFrame.highlightPosition(line, column);
this._historyManager.pushNewState();
},
/**
* @param {string} id
* @param {!WebInspector.SidebarPane} pane
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment