Diff
Modified: trunk/Source/WebCore/ChangeLog (116215 => 116216)
--- trunk/Source/WebCore/ChangeLog 2012-05-05 09:38:41 UTC (rev 116215)
+++ trunk/Source/WebCore/ChangeLog 2012-05-05 09:46:20 UTC (rev 116216)
@@ -1,3 +1,23 @@
+2012-05-05 Pavel Feldman <[email protected]>
+
+ Web Inspector: simplify the _javascript_Outline dialog interaction.
+ https://bugs.webkit.org/show_bug.cgi?id=85701
+
+ Reviewed by Yury Semikhatsky.
+
+ Removed bidirectional dependency between scripts panel and outline dialog.
+
+ * inspector/front-end/FilteredItemSelectionDialog.js:
+ (WebInspector._javascript_OutlineDialog):
+ (WebInspector._javascript_OutlineDialog.show):
+ (WebInspector._javascript_OutlineDialog.prototype.requestItems):
+ (WebInspector._javascript_OutlineDialog.prototype._didBuildOutlineChunk):
+ (WebInspector._javascript_OutlineDialog.prototype.selectItem):
+ * inspector/front-end/ScriptFormatterWorker.js:
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.addToWatch):
+ (WebInspector.ScriptsPanel.prototype._showJavaScriptOutlineDialog):
+
2012-05-04 Ilya Tikhonovsky <[email protected]>
Web Inspector: annotate ProfilerAgent.
Modified: trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js (116215 => 116216)
--- trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js 2012-05-05 09:38:41 UTC (rev 116215)
+++ trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js 2012-05-05 09:46:20 UTC (rev 116216)
@@ -462,55 +462,29 @@
/**
* @constructor
* @implements {WebInspector.SelectionDialogContentProvider}
+ * @param {WebInspector.View} view
+ * @param {WebInspector.ContentProvider} contentProvider
*/
-WebInspector._javascript_OutlineDialog = function(panel, view)
+WebInspector._javascript_OutlineDialog = function(view, contentProvider)
{
WebInspector.SelectionDialogContentProvider.call(this);
this._functionItems = [];
-
- this._panel = panel;
this._view = view;
+ this._contentProvider = contentProvider;
}
/**
- * @param {{chunk, index, total, id}} data
+ * @param {WebInspector.View} view
+ * @param {WebInspector.ContentProvider} contentProvider
*/
-WebInspector._javascript_OutlineDialog.didAddChunk = function(data)
+WebInspector._javascript_OutlineDialog.show = function(view, contentProvider)
{
- var instance = WebInspector._javascript_OutlineDialog._instance;
- if (!instance)
- return;
-
- if (data.id !== instance._view.uiSourceCode.id)
- return;
-
- instance._appendItemElements(data.chunk, data.index, data.total);
-},
-
-WebInspector._javascript_OutlineDialog.install = function(panel, viewGetter)
-{
- function showJavaScriptOutlineDialog()
- {
- var view = viewGetter();
- if (view)
- WebInspector._javascript_OutlineDialog._show(panel, view);
- }
-
- var _javascript_OutlineShortcut = WebInspector._javascript_OutlineDialog.createShortcut();
- panel.registerShortcut(_javascript_OutlineShortcut.key, showJavaScriptOutlineDialog);
-}
-
-WebInspector._javascript_OutlineDialog._show = function(panel, sourceView)
-{
if (WebInspector.Dialog.currentInstance())
- return;
- if (!sourceView || !sourceView.canHighlightLine())
- return;
- WebInspector._javascript_OutlineDialog._instance = new WebInspector._javascript_OutlineDialog(panel, sourceView);
-
- var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(WebInspector._javascript_OutlineDialog._instance);
- WebInspector.Dialog.show(sourceView.element, filteredItemSelectionDialog);
+ return null;
+ var delegate = new WebInspector._javascript_OutlineDialog(view, contentProvider);
+ var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(delegate);
+ WebInspector.Dialog.show(view.element, filteredItemSelectionDialog);
}
WebInspector._javascript_OutlineDialog.createShortcut = function()
@@ -551,10 +525,39 @@
*/
requestItems: function(callback)
{
- this._itemsAddedCallback = callback;
- this._panel.requestVisibleScriptOutline();
+ /**
+ * @param {?string} content
+ * @param {boolean} contentEncoded
+ * @param {string} mimeType
+ */
+ function contentCallback(content, contentEncoded, mimeType)
+ {
+ if (this._outlineWorker)
+ this._outlineWorker.terminate();
+ this._outlineWorker = new Worker("ScriptFormatterWorker.js");
+ this._outlineWorker._onmessage_ = this._didBuildOutlineChunk.bind(this, callback);
+ const method = "outline";
+ this._outlineWorker.postMessage({ method: method, params: { content: content } });
+ }
+ this._contentProvider.requestContent(contentCallback.bind(this));
},
+ _didBuildOutlineChunk: function(callback, event)
+ {
+ var data = ""
+
+ var index = this._functionItems.length;
+ var chunk = data["chunk"];
+ for (var i = 0; i < chunk.length; ++i)
+ this._functionItems.push(chunk[i]);
+ callback(index, chunk.length, data.index, data.total);
+
+ if (data.total === data.index && this._outlineWorker) {
+ this._outlineWorker.terminate();
+ delete this._outlineWorker;
+ }
+ },
+
/**
* @param {number} itemIndex
*/
@@ -564,21 +567,6 @@
if (!isNaN(lineNumber) && lineNumber >= 0)
this._view.highlightLine(lineNumber);
this._view.focus();
- delete WebInspector._javascript_OutlineDialog._instance;
- },
-
- /**
- * @param {Array.<Object>} chunk
- * @param {number} chunkIndex
- * @param {number} chunkCount
- */
- _appendItemElements: function(chunk, chunkIndex, chunkCount)
- {
- var index = this._functionItems.length;
- for (var i = 0; i < chunk.length; ++i) {
- this._functionItems.push(chunk[i]);
- }
- this._itemsAddedCallback(index, chunk.length, chunkIndex, chunkCount);
}
}
Modified: trunk/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js (116215 => 116216)
--- trunk/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js 2012-05-05 09:38:41 UTC (rev 116215)
+++ trunk/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js 2012-05-05 09:46:20 UTC (rev 116216)
@@ -130,13 +130,13 @@
column = newColumn;
if (processedChunkCharacters >= chunkSize) {
- postMessage({ chunk: outlineChunk, id: params.id, total: chunkCount, index: currentChunk++ });
+ postMessage({ chunk: outlineChunk, total: chunkCount, index: currentChunk++ });
outlineChunk = [];
processedChunkCharacters = 0;
}
} while (column < line.length);
}
- postMessage({ chunk: outlineChunk, id: params.id, total: chunkCount, index: chunkCount });
+ postMessage({ chunk: outlineChunk, total: chunkCount, index: chunkCount });
}
function formatScript(content, mapping, offset, formattedOffset, indentString)
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (116215 => 116216)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-05-05 09:38:41 UTC (rev 116215)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-05-05 09:46:20 UTC (rev 116216)
@@ -44,7 +44,6 @@
return this.visibleView;
}
WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
- WebInspector._javascript_OutlineDialog.install(this, viewGetter.bind(this));
this.debugToolbar = this._createDebugToolbar();
@@ -126,6 +125,7 @@
var scriptOutlineShortcut = WebInspector._javascript_OutlineDialog.createShortcut();
helpSection.addKey(scriptOutlineShortcut.name, WebInspector.UIString("Go to function"));
+ this.registerShortcut(scriptOutlineShortcut.key, this._showJavaScriptOutlineDialog.bind(this));
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.");
@@ -213,17 +213,6 @@
this._navigatorController.wasShown();
},
- _didBuildOutlineChunk: function(event)
- {
- WebInspector._javascript_OutlineDialog.didAddChunk(event.data);
- if (event.data.total === event.data.index) {
- if (this._outlineWorker) {
- this._outlineWorker.terminate();
- delete this._outlineWorker;
- }
- }
- },
-
/**
* @param {WebInspector.Event} event
*/
@@ -449,28 +438,6 @@
return sourceFrame;
},
- requestVisibleScriptOutline: function()
- {
-
- /**
- * @param {?string} content
- * @param {boolean} contentEncoded
- * @param {string} mimeType
- */
- function contentCallback(content, contentEncoded, mimeType)
- {
- if (this._outlineWorker)
- this._outlineWorker.terminate();
- this._outlineWorker = new Worker("ScriptFormatterWorker.js");
- this._outlineWorker._onmessage_ = this._didBuildOutlineChunk.bind(this);
- const method = "outline";
- this._outlineWorker.postMessage({ method: method, params: { content: content, id: this.visibleView.uiSourceCode.id } });
- }
-
- if (this.visibleView.uiSourceCode)
- this.visibleView.uiSourceCode.requestContent(contentCallback.bind(this));
- },
-
/**
* @param {WebInspector.UISourceCode} uiSourceCode
* @return {WebInspector.SourceFrame}
@@ -952,6 +919,11 @@
addToWatch: function(_expression_)
{
this.sidebarPanes.watchExpressions.addExpression(_expression_);
+ },
+
+ _showJavaScriptOutlineDialog: function()
+ {
+ WebInspector._javascript_OutlineDialog.show(this.visibleView, this.visibleView);
}
}