Web Inspector: Enable support for Open Script dialog based on FilteredItemSelectionDi...
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 14:20:26 +0000 (14:20 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 14:20:26 +0000 (14:20 +0000)
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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105272 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js
Source/WebCore/inspector/front-end/ScriptsPanel.js

index 4fb9276..561a442 100644 (file)
@@ -1,3 +1,26 @@
+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.
index 693b473..48f9132 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index fbce03a..2f76121 100644 (file)
@@ -513,9 +513,7 @@ WebInspector.JavaScriptOutlineDialog._show = function(panel, sourceView)
 
 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 = {
@@ -582,3 +580,106 @@ 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;
index ab1cd57..78ef4d1 100644 (file)
@@ -43,6 +43,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
     }
     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();
 
@@ -129,6 +130,9 @@ WebInspector.ScriptsPanel = function(presentationModel)
     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");
@@ -459,6 +463,11 @@ WebInspector.ScriptsPanel.prototype = {
         this._showSourceLine(uiLocation.uiSourceCode, uiLocation.lineNumber);
     },
 
+    showUISourceCode: function(uiSourceCode)
+    {
+        this._showSourceLine(uiSourceCode, null);
+    },
+
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {number} lineNumber