Title: [114878] trunk/Source/WebCore
Revision
114878
Author
pfeld...@chromium.org
Date
2012-04-23 01:05:36 -0700 (Mon, 23 Apr 2012)

Log Message

Web Inspector: implement "open stylesheet" dialog.
https://bugs.webkit.org/show_bug.cgi?id=84466

Reviewed by Yury Semikhatsky.

This change introduces abstract OpenResourceDialog and re-uses it in OpenScriptDialog and OpenStylesheetDialog.
Drive-by fix for data: url representation in the navigator and open resource dialogs.

* inspector/front-end/FilteredItemSelectionDialog.js:
(WebInspector.FilteredItemSelectionDialog.prototype.position):
(WebInspector.OpenResourceDialog.filterOutEmptyURLs):
(WebInspector.OpenResourceDialog.compareFunction):
(WebInspector.OpenResourceDialog):
(WebInspector.OpenResourceDialog.prototype.itemTitleAt):
(WebInspector.OpenResourceDialog.prototype.itemKeyAt):
(WebInspector.OpenResourceDialog.prototype.itemsCount):
(WebInspector.OpenResourceDialog.prototype.requestItems):
(WebInspector.OpenResourceDialog.prototype.selectItem):
(WebInspector.OpenScriptDialog):
(WebInspector.OpenScriptDialog.install):
(WebInspector.OpenScriptDialog._show):
(WebInspector.OpenScriptDialog.prototype.selectItem):
* inspector/front-end/ResourceUtils.js:
(WebInspector.ParsedURL):
* inspector/front-end/ScriptsPanel.js:
* inspector/front-end/StylesPanel.js:
(WebInspector.StylesPanel):
(WebInspector.StylesPanel.prototype._showOpenStylesheetDialog):
(WebInspector.OpenStylesheetDialog):
(WebInspector.OpenStylesheetDialog.prototype.selectItem):
* inspector/front-end/inspector.html:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114877 => 114878)


--- trunk/Source/WebCore/ChangeLog	2012-04-23 08:00:08 UTC (rev 114877)
+++ trunk/Source/WebCore/ChangeLog	2012-04-23 08:05:36 UTC (rev 114878)
@@ -1,3 +1,37 @@
+2012-04-20  Pavel Feldman  <pfeld...@chromium.org>
+
+        Web Inspector: implement "open stylesheet" dialog.
+        https://bugs.webkit.org/show_bug.cgi?id=84466
+
+        Reviewed by Yury Semikhatsky.
+
+        This change introduces abstract OpenResourceDialog and re-uses it in OpenScriptDialog and OpenStylesheetDialog.
+        Drive-by fix for data: url representation in the navigator and open resource dialogs.
+
+        * inspector/front-end/FilteredItemSelectionDialog.js:
+        (WebInspector.FilteredItemSelectionDialog.prototype.position):
+        (WebInspector.OpenResourceDialog.filterOutEmptyURLs):
+        (WebInspector.OpenResourceDialog.compareFunction):
+        (WebInspector.OpenResourceDialog):
+        (WebInspector.OpenResourceDialog.prototype.itemTitleAt):
+        (WebInspector.OpenResourceDialog.prototype.itemKeyAt):
+        (WebInspector.OpenResourceDialog.prototype.itemsCount):
+        (WebInspector.OpenResourceDialog.prototype.requestItems):
+        (WebInspector.OpenResourceDialog.prototype.selectItem):
+        (WebInspector.OpenScriptDialog):
+        (WebInspector.OpenScriptDialog.install):
+        (WebInspector.OpenScriptDialog._show):
+        (WebInspector.OpenScriptDialog.prototype.selectItem):
+        * inspector/front-end/ResourceUtils.js:
+        (WebInspector.ParsedURL):
+        * inspector/front-end/ScriptsPanel.js:
+        * inspector/front-end/StylesPanel.js:
+        (WebInspector.StylesPanel):
+        (WebInspector.StylesPanel.prototype._showOpenStylesheetDialog):
+        (WebInspector.OpenStylesheetDialog):
+        (WebInspector.OpenStylesheetDialog.prototype.selectItem):
+        * inspector/front-end/inspector.html:
+
 2012-04-23  Kent Tamura  <tk...@chromium.org>
 
         Add test function to get placeholder string

Modified: trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js (114877 => 114878)


--- trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js	2012-04-23 08:00:08 UTC (rev 114877)
+++ trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js	2012-04-23 08:05:36 UTC (rev 114878)
@@ -86,7 +86,7 @@
         this.element.style.width = width + "px";
         this.element.style.height = height + "px";
 
-        const shadowPadding = 10;
+        const shadowPadding = 20; // shadow + padding
         element.positionAt(
             relativeToElement.totalOffsetLeft() + Math.max((relativeToElement.offsetWidth - width - 2 * shadowPadding) / 2, shadowPadding),
             relativeToElement.totalOffsetTop() + Math.max((relativeToElement.offsetHeight - height - 2 * shadowPadding) / 2, shadowPadding));
@@ -587,60 +587,28 @@
 /**
  * @constructor
  * @implements {WebInspector.SelectionDialogContentProvider}
- * @param {WebInspector.ScriptsPanel} panel
- * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ * @param {Array.<WebInspector.Resource>} resources
  */
-WebInspector.OpenResourceDialog = function(panel, presentationModel)
+WebInspector.OpenResourceDialog = function(resources)
 {
+    // FIXME: migrate from WebInspector.Resource to WebInspector.Source (base for Resource and UISourceCode) and make this dialog OpenSource.
     WebInspector.SelectionDialogContentProvider.call(this);
 
-    this._panel = panel;
-    this._uiSourceCodes = presentationModel.uiSourceCodes();
+    this.resources = resources;
 
-    function filterOutEmptyURLs(uiSourceCode)
+    function filterOutEmptyURLs(resource)
     {
-        return !!uiSourceCode.parsedURL.lastPathComponent;
+        return !!resource.parsedURL.lastPathComponent;
     }
+    this.resources = this.resources.filter(filterOutEmptyURLs);
 
-    this._uiSourceCodes = this._uiSourceCodes.filter(filterOutEmptyURLs);
-
-    function compareFunction(uiSourceCode1, uiSourceCode2)
+    function compareFunction(resource1, resource2)
     {
-        return uiSourceCode1.parsedURL.lastPathComponent.localeCompare(uiSourceCode2.parsedURL.lastPathComponent);
+        return resource1.parsedURL.lastPathComponent.localeCompare(resource2.parsedURL.lastPathComponent);
     }
-
-    this._uiSourceCodes.sort(compareFunction);
+    this.resources.sort(compareFunction);
 }
 
-/**
- * @param {WebInspector.ScriptsPanel} panel
- * @param {WebInspector.DebuggerPresentationModel} presentationModel
- */
-WebInspector.OpenResourceDialog.install = function(panel, presentationModel, relativeToElement)
-{
-    function showOpenResourceDialog()
-    {
-        WebInspector.OpenResourceDialog._show(panel, presentationModel, relativeToElement);
-    }
-
-    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("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta);
@@ -653,7 +621,7 @@
      */
     itemTitleAt: function(itemIndex)
     {
-        return this._uiSourceCodes[itemIndex].parsedURL.lastPathComponent;
+        return this.resources[itemIndex].parsedURL.lastPathComponent;
     },
 
     /**
@@ -662,7 +630,7 @@
      */
     itemKeyAt: function(itemIndex)
     {
-        return this._uiSourceCodes[itemIndex].parsedURL.lastPathComponent;
+        return this.resources[itemIndex].parsedURL.lastPathComponent;
     },
 
     /**
@@ -670,7 +638,7 @@
      */
     itemsCount: function()
     {
-        return this._uiSourceCodes.length;
+        return this.resources.length;
     },
 
     /**
@@ -678,7 +646,7 @@
      */
     requestItems: function(callback)
     {
-        callback(0, this._uiSourceCodes.length, 1, 1);
+        callback(0, this.resources.length, 1, 1);
     },
 
     /**
@@ -686,8 +654,61 @@
      */
     selectItem: function(itemIndex)
     {
-        this._panel.showUISourceCode(this._uiSourceCodes[itemIndex]);
+        // Overriden by descendants;
     }
 }
 
 WebInspector.OpenResourceDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.OpenResourceDialog}
+ * @param {WebInspector.ScriptsPanel} panel
+ * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ */
+WebInspector.OpenScriptDialog = function(panel, presentationModel)
+{
+    WebInspector.OpenResourceDialog.call(this, presentationModel.uiSourceCodes());
+    this._panel = panel;
+}
+
+/**
+ * @param {WebInspector.ScriptsPanel} panel
+ * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ */
+WebInspector.OpenScriptDialog.install = function(panel, presentationModel, relativeToElement)
+{
+    function showOpenResourceDialog()
+    {
+        WebInspector.OpenScriptDialog._show(panel, presentationModel, relativeToElement);
+    }
+
+    var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
+    panel.registerShortcut(openResourceShortcut.key, showOpenResourceDialog);
+}
+
+/**
+ * @param {WebInspector.ScriptsPanel} panel
+ * @param {WebInspector.DebuggerPresentationModel} presentationModel
+ * @param {Element} relativeToElement
+ */
+WebInspector.OpenScriptDialog._show = function(panel, presentationModel, relativeToElement)
+{
+    if (WebInspector.Dialog.currentInstance())
+        return;
+
+    var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenScriptDialog(panel, presentationModel));
+    WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
+}
+
+WebInspector.OpenScriptDialog.prototype = {
+    /**
+     * @param {number} itemIndex
+     */
+    selectItem: function(itemIndex)
+    {
+        this._panel.showUISourceCode(this.resources[itemIndex]);
+    }
+}
+
+WebInspector.OpenScriptDialog.prototype.__proto__ = WebInspector.OpenResourceDialog.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/ResourceUtils.js (114877 => 114878)


--- trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2012-04-23 08:00:08 UTC (rev 114877)
+++ trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2012-04-23 08:05:36 UTC (rev 114878)
@@ -60,8 +60,14 @@
         this.path = match[4] || "/";
         this.fragment = match[5];
     } else {
-        if (this == "about:blank") {
+        if (this.url.indexOf("data:") == 0) {
             this.isValid = true;
+            this.path = this.url;
+            this.lastPathComponent = this.path;
+            return;
+        }
+        if (this.url == "about:blank") {
+            this.isValid = true;
             this.scheme = "about";
             this.host = "blank";
             this.path = "/";

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (114877 => 114878)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-04-23 08:00:08 UTC (rev 114877)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-04-23 08:05:36 UTC (rev 114878)
@@ -76,7 +76,7 @@
 
     this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previouslyViewedFiles");
     this._editorContainer.show(this.editorView.mainElement);
-    WebInspector.OpenResourceDialog.install(this, this._presentationModel, this.editorView.mainElement);
+    WebInspector.OpenScriptDialog.install(this, this._presentationModel, this.editorView.mainElement);
 
     this._navigatorController = new WebInspector.NavigatorOverlayController(this, this.editorView, this._navigator.view, this._editorContainer.view);
 

Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (114877 => 114878)


--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-04-23 08:00:08 UTC (rev 114877)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-04-23 08:05:36 UTC (rev 114878)
@@ -58,19 +58,22 @@
     this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previouslyViewedCSSFiles");
     this._editorContainer.show(this._mainView.mainElement);
 
+    this._mainView.show(this.element);
+
     this._navigatorController = new WebInspector.NavigatorOverlayController(this, this._mainView, this._tabbedPane, this._editorContainer.view);
 
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._cachedResourcesLoaded, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.WillLoadCachedResources, this._reset, this);
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._reset, this);
 
-    this._mainView.show(this.element);
     this._sourceFramesForResource = new Map();
     this._urlToResource = {};
+
+    var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
+    this.registerShortcut(openResourceShortcut.key, this._showOpenStylesheetDialog.bind(this));
 }
 
 WebInspector.StylesPanel.prototype = {
-
     wasShown: function()
     {
         WebInspector.Panel.prototype.wasShown.call(this);
@@ -184,7 +187,43 @@
         if (typeof anchor.lineNumber === "number")
             sourceFrame.highlightLine(anchor.lineNumber);
         this._editorContainer.view.focus();
+    },
+
+    _showOpenStylesheetDialog: function()
+    {
+        if (WebInspector.Dialog.currentInstance())
+            return;
+
+        var dialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenStylesheetDialog(this));
+        WebInspector.Dialog.show(this.element, dialog);
     }
 }
 
 WebInspector.StylesPanel.prototype.__proto__ = WebInspector.Panel.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.OpenResourceDialog}
+ * @param {WebInspector.StylesPanel} panel
+ */
+WebInspector.OpenStylesheetDialog = function(panel)
+{
+    var resources = [];
+    for (var url in panel._urlToResource)
+        resources.push(panel._urlToResource[url]);
+    WebInspector.OpenResourceDialog.call(this, resources);
+
+    this._panel = panel;
+}
+
+WebInspector.OpenStylesheetDialog.prototype = {
+    /**
+     * @param {number} itemIndex
+     */
+    selectItem: function(itemIndex)
+    {
+        this._panel._showFile(this.resources[itemIndex]);
+    }
+}
+
+WebInspector.OpenStylesheetDialog.prototype.__proto__ = WebInspector.OpenResourceDialog.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (114877 => 114878)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2012-04-23 08:00:08 UTC (rev 114877)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2012-04-23 08:05:36 UTC (rev 114878)
@@ -128,7 +128,6 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
-    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
@@ -207,6 +206,7 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
 </head>
 <body class="detached" id="-webkit-web-inspector">
     <div id="toolbar">
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to