+2012-01-17 Vsevolod Vlasov <vsevik@chromium.org>
+
+ Web Inspector: Enable support for Open Script dialog based on FilteredItemSelectionDialog.
+ https://bugs.webkit.org/show_bug.cgi?id=76466
+
+ Reviewed by Pavel Feldman.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/FilteredItemSelectionDialog.js:
+ (WebInspector.JavaScriptOutlineDialog.createShortcut):
+ (WebInspector.OpenResourceDialog.filterOutEmptyURLs):
+ (WebInspector.OpenResourceDialog):
+ (WebInspector.OpenResourceDialog.install):
+ (WebInspector.OpenResourceDialog._show):
+ (WebInspector.OpenResourceDialog.createShortcut):
+ (WebInspector.OpenResourceDialog.prototype.itemTitleAt):
+ (WebInspector.OpenResourceDialog.prototype.itemKeyAt):
+ (WebInspector.OpenResourceDialog.prototype.itemsCount):
+ (WebInspector.OpenResourceDialog.prototype.requestItems):
+ (WebInspector.OpenResourceDialog.prototype.selectItem):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.showUISourceCode):
+
2012-01-18 Pavel Feldman <pfeldman@google.com>
Not reviewed: follow up to r105262, fixing front-end compilation.
WebInspector.JavaScriptOutlineDialog.createShortcut = function()
{
- if (WebInspector.isMac())
- return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.Meta);
- return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.Ctrl);
+ return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta);
}
WebInspector.JavaScriptOutlineDialog.prototype = {
}
WebInspector.JavaScriptOutlineDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype;
+
+/**
+ * @constructor
+ * @implements {WebInspector.SelectionDialogContentProvider}
+ * @param {WebInspector.ScriptsPanel} panel
+ * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ */
+WebInspector.OpenResourceDialog = function(panel, presentationModel)
+{
+ WebInspector.SelectionDialogContentProvider.call(this);
+
+ this._panel = panel;
+ this._uiSourceCodes = presentationModel.uiSourceCodes();
+
+ function filterOutEmptyURLs(uiSourceCode)
+ {
+ return !!uiSourceCode.fileName;
+ }
+
+ this._uiSourceCodes = this._uiSourceCodes.filter(filterOutEmptyURLs);
+}
+
+/**
+ * @param {WebInspector.ScriptsPanel} panel
+ * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ */
+WebInspector.OpenResourceDialog.install = function(panel, presentationModel, viewGetter)
+{
+ function showOpenResourceDialog()
+ {
+ var view = viewGetter();
+ if (view)
+ WebInspector.OpenResourceDialog._show(panel, presentationModel, view.element);
+ }
+
+ var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
+ panel.registerShortcut(openResourceShortcut.key, showOpenResourceDialog);
+}
+
+/**
+ * @param {WebInspector.ScriptsPanel} panel
+ * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ * @param {Element} relativeToElement
+ */
+WebInspector.OpenResourceDialog._show = function(panel, presentationModel, relativeToElement)
+{
+ if (WebInspector.Dialog.currentInstance())
+ return;
+
+ var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel, presentationModel));
+ WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
+}
+
+WebInspector.OpenResourceDialog.createShortcut = function()
+{
+ return WebInspector.KeyboardShortcut.makeDescriptor("t", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
+}
+
+WebInspector.OpenResourceDialog.prototype = {
+ /**
+ * @param {number} itemIndex
+ * @return {string}
+ */
+ itemTitleAt: function(itemIndex)
+ {
+ return this._uiSourceCodes[itemIndex].fileName;
+ },
+
+ /**
+ * @param {number} itemIndex
+ * @return {string}
+ */
+ itemKeyAt: function(itemIndex)
+ {
+ return this._uiSourceCodes[itemIndex].fileName;
+ },
+
+ /**
+ * @return {number}
+ */
+ itemsCount: function()
+ {
+ return this._uiSourceCodes.length;
+ },
+
+ /**
+ * @param {function(number, number, number, number)} callback
+ */
+ requestItems: function(callback)
+ {
+ callback(0, this._uiSourceCodes.length, 1, 1);
+ },
+
+ /**
+ * @param {number} itemIndex
+ */
+ selectItem: function(itemIndex)
+ {
+ this._panel.showUISourceCode(this._uiSourceCodes[itemIndex]);
+ }
+}
+
+WebInspector.OpenResourceDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype;
}
WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
WebInspector.JavaScriptOutlineDialog.install(this, viewGetter.bind(this));
+ WebInspector.OpenResourceDialog.install(this, this._presentationModel, viewGetter.bind(this));
this.debugToolbar = this._createDebugToolbar();
var scriptOutlineShortcut = WebInspector.JavaScriptOutlineDialog.createShortcut();
helpSection.addKey(scriptOutlineShortcut.name, WebInspector.UIString("Go to Function"));
+ var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
+ helpSection.addKey(openResourceShortcut.name, WebInspector.UIString("Open Script"));
+
var panelEnablerHeading = WebInspector.UIString("You need to enable debugging before you can use the Scripts panel.");
var panelEnablerDisclaimer = WebInspector.UIString("Enabling debugging will make scripts run slower.");
var panelEnablerButton = WebInspector.UIString("Enable Debugging");
this._showSourceLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
},
+ showUISourceCode: function(uiSourceCode)
+ {
+ this._showSourceLine(uiSourceCode, null);
+ },
+
/**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber