Diff
Modified: trunk/Source/WebCore/ChangeLog (103681 => 103682)
--- trunk/Source/WebCore/ChangeLog 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/ChangeLog 2011-12-26 12:39:39 UTC (rev 103682)
@@ -1,3 +1,53 @@
+2011-12-26 Alexander Pavlov <[email protected]>
+
+ Web Inspector: Implement "Go to Function" dialog for _javascript_
+ https://bugs.webkit.org/show_bug.cgi?id=75092
+
+ Reviewed by Pavel Feldman.
+
+ * English.lproj/localizedStrings.js:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/compile-front-end.sh:
+ * inspector/front-end/_javascript_OutlineDialog.js: Added.
+ (WebInspector._javascript_OutlineDialog.onMouseDown):
+ (WebInspector._javascript_OutlineDialog):
+ (WebInspector._javascript_OutlineDialog.didAddChunk):
+ (WebInspector._javascript_OutlineDialog.install):
+ (WebInspector._javascript_OutlineDialog._show):
+ (WebInspector._javascript_OutlineDialog.createShortcut):
+ (WebInspector._javascript_OutlineDialog.prototype._resizeWindow):
+ (WebInspector._javascript_OutlineDialog.prototype._appendItemElements):
+ (WebInspector._javascript_OutlineDialog.prototype._createSearchRegExp):
+ (WebInspector._javascript_OutlineDialog.prototype._filterFunctions):
+ (WebInspector._javascript_OutlineDialog.prototype._selectFirstItem):
+ (WebInspector._javascript_OutlineDialog.prototype._hide):
+ (WebInspector._javascript_OutlineDialog.prototype._onBlur):
+ (WebInspector._javascript_OutlineDialog.prototype._onKeyDown.previousItem):
+ (WebInspector._javascript_OutlineDialog.prototype._onKeyDown.nextItem):
+ (WebInspector._javascript_OutlineDialog.prototype._onKeyDown):
+ (WebInspector._javascript_OutlineDialog.prototype._scheduleFilter):
+ (WebInspector._javascript_OutlineDialog.prototype._updateSelection):
+ (WebInspector._javascript_OutlineDialog.prototype._onClick):
+ (WebInspector._javascript_OutlineDialog.prototype._onMouseMove):
+ (WebInspector._javascript_OutlineDialog.prototype._highlightFunctionLine):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype.get uiSourceCode):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._didBuildOutlineChunk):
+ (WebInspector.ScriptsPanel.prototype._reset):
+ (WebInspector.ScriptsPanel.prototype.requestVisibleScriptOutline):
+ (WebInspector.ScriptsPanel.prototype._createEditorToolbar):
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+ * inspector/front-end/_javascript_OutlineDialog.css: Added.
+ (.js-outline-dialog):
+ (.js-outline-dialog > input):
+ (.js-outline-dialog > div.progress):
+ (.js-outline-dialog > div.container):
+ (.js-outline-dialog > .container > div.item):
+ (.js-outline-dialog > .container > div.item.selected):
+
2011-12-26 Pavel Feldman <[email protected]>
Web Inspector: make SDK compilation component self-contained.
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js
(Binary files differ)
Modified: trunk/Source/WebCore/WebCore.gypi (103681 => 103682)
--- trunk/Source/WebCore/WebCore.gypi 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/WebCore.gypi 2011-12-26 12:39:39 UTC (rev 103682)
@@ -6431,6 +6431,7 @@
'inspector/front-end/InjectedFakeWorker.js',
'inspector/front-end/inspector.js',
'inspector/front-end/_javascript_Formatter.js',
+ 'inspector/front-end/_javascript_OutlineDialog.js',
'inspector/front-end/_javascript_SourceFrame.js',
'inspector/front-end/KeyboardShortcut.js',
'inspector/front-end/MetricsSidebarPane.js',
@@ -6514,6 +6515,7 @@
'inspector/front-end/WorkerManager.js',
'inspector/front-end/WorkersSidebarPane.js',
'inspector/front-end/goToLineDialog.css',
+ 'inspector/front-end/_javascript_OutlineDialog.css',
'inspector/front-end/helpScreen.css',
'inspector/front-end/inspector.css',
'inspector/front-end/inspectorSyntaxHighlight.css',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (103681 => 103682)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-12-26 12:39:39 UTC (rev 103682)
@@ -71745,6 +71745,14 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\_javascript_OutlineDialog.js"
+ >
+ </File>
+ <File
+ RelativePath="..\inspector\front-end\_javascript_OutlineDialog.css"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\_javascript_SourceFrame.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/compile-front-end.sh (103681 => 103682)
--- trunk/Source/WebCore/inspector/compile-front-end.sh 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/inspector/compile-front-end.sh 2011-12-26 12:39:39 UTC (rev 103682)
@@ -110,7 +110,7 @@
--js Source/WebCore/inspector/front-end/UIUtils.js \
--js Source/WebCore/inspector/front-end/View.js \
--js Source/WebCore/inspector/front-end/WelcomeView.js \
- --module jsmodule_components:15:jsmodule_sdk,jsmodule_ui \
+ --module jsmodule_components:16:jsmodule_sdk,jsmodule_ui \
--js Source/WebCore/inspector/front-end/ConsoleMessage.js \
--js Source/WebCore/inspector/front-end/BreakpointsSidebarPane.js \
--js Source/WebCore/inspector/front-end/DOMBreakpointsSidebarPane.js \
@@ -119,6 +119,7 @@
--js Source/WebCore/inspector/front-end/EventListenersSidebarPane.js \
--js Source/WebCore/inspector/front-end/GoToLineDialog.js \
--js Source/WebCore/inspector/front-end/_javascript_ContextManager.js \
+ --js Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js \
--js Source/WebCore/inspector/front-end/ObjectPopoverHelper.js \
--js Source/WebCore/inspector/front-end/ObjectPropertiesSection.js \
--js Source/WebCore/inspector/front-end/SourceFrame.js \
Added: trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js (0 => 103682)
--- trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js 2011-12-26 12:39:39 UTC (rev 103682)
@@ -0,0 +1,428 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ */
+WebInspector._javascript_OutlineDialog = function(panel, view)
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "_javascript_OutlineDialog.css", false);
+ xhr.send(null);
+
+ this._element = document.createElement("div");
+ this._element.className = "js-outline-dialog";
+ this._element.addEventListener("keydown", this._onKeyDown.bind(this), false);
+ this._element.addEventListener("mousemove", this._onMouseMove.bind(this), false);
+ this._element.addEventListener("click", this._onClick.bind(this), false);
+ var styleElement = this._element.createChild("style");
+ styleElement.type = "text/css";
+ styleElement.textContent = xhr.responseText;
+
+ this._closeKeys = [
+ WebInspector.KeyboardShortcut.Keys.Enter.code,
+ WebInspector.KeyboardShortcut.Keys.Esc.code,
+ ];
+ this._itemElements = [];
+ this._previousInputLength = 0;
+ this._visibleElements = [];
+
+ var dialogWindow = this._element;
+ this._boundBlurHandler = this._onBlur.bind(this);
+
+ this._promptElement = dialogWindow.createChild("input", "monospace");
+ this._promptElement.type = "text";
+ this._promptElement.setAttribute("spellcheck", "false");
+ this._promptElement.addEventListener("blur", this._boundBlurHandler, false);
+
+ function onMouseDown(event)
+ {
+ if (event.target === this._promptElement)
+ return;
+ var itemElement = event.target.enclosingNodeOrSelfWithClass("item");
+ if (!itemElement) {
+ event.stopPropagation();
+ event.preventDefault();
+ }
+
+ // Prevent blur listener from prematurely closing the dialog when an item is clicked.
+ this._promptElement.removeEventListener("blur", this._boundBlurHandler, false);
+ }
+ this._element.addEventListener("mousedown", onMouseDown.bind(this), false);
+
+ this._progressElement = dialogWindow.createChild("div", "progress");
+
+ this._functionItemContainer = document.createElement("div");
+ this._functionItemContainer.className = "container monospace";
+
+ this._panel = panel;
+ this._view = view;
+
+ this._panel.requestVisibleScriptOutline();
+ this._resizeWindow();
+
+ this._previousFocusElement = WebInspector.currentFocusElement();
+ WebInspector.setCurrentFocusElement(this._promptElement);
+ this._promptElement.select();
+}
+
+/**
+ * @param {{chunk, index, total, id}} data
+ */
+WebInspector._javascript_OutlineDialog.didAddChunk = function(data)
+{
+ var instance = WebInspector._javascript_OutlineDialog._instance;
+ if (!instance)
+ return;
+
+ if (data.id !== instance._view.uiSourceCode.id)
+ return;
+
+ instance._appendItemElements(data.chunk);
+
+ if (data.index === data.total) {
+ instance._progressElement.style.backgroundImage = "";
+ instance._filterFunctions();
+ } else {
+ const color = "rgb(66, 129, 235)";
+ const percent = ((data.index / data.total) * 100) + "%";
+ instance._progressElement.style.backgroundImage = "-webkit-linear-gradient(left, " + color + ", " + color + " " + percent + ", transparent " + percent + ")";
+ }
+},
+
+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 (!sourceView || !sourceView.canHighlightLine())
+ return;
+ if (WebInspector._javascript_OutlineDialog._instance)
+ return;
+ WebInspector._javascript_OutlineDialog._instance = new WebInspector._javascript_OutlineDialog(panel, sourceView);
+}
+
+WebInspector._javascript_OutlineDialog.createShortcut = function()
+{
+ if (WebInspector.isMac())
+ return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.Meta);
+ return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.Ctrl);
+}
+
+WebInspector._javascript_OutlineDialog.prototype = {
+ _resizeWindow: function()
+ {
+ const minWidth = 500;
+ const minHeight = 204;
+ const totalWidthDelta = 40;
+ const totalHeightDelta = 78;
+ this._element.appendChild(this._functionItemContainer);
+ var width = Math.max(this._view.element.offsetWidth * 2 / 3, minWidth);
+ var height = Math.max(this._view.element.offsetHeight * 2 / 3, minHeight);
+
+ const shadowPadding = 10;
+ this._element.positionAt(
+ this._view.element.totalOffsetLeft() + Math.max(this._view.element.offsetWidth - width - shadowPadding, shadowPadding),
+ this._view.element.totalOffsetTop() + Math.max((this._view.element.offsetHeight - height) / 2 + shadowPadding, shadowPadding));
+ this._element.style.width = width + "px";
+ this._element.style.height = height + "px";
+
+ document.body.appendChild(this._element);
+ },
+
+ _appendItemElements: function(chunk)
+ {
+ var regExp;
+ if (this._promptElement.value)
+ regExp = this._createSearchRegExp(this._promptElement.value);
+ var fragment = document.createDocumentFragment();
+ var candidateItem = this._selectedElement;
+ for (var i = 0; i < chunk.length; ++i) {
+ var isVisible = true;
+ var entry = chunk[i];
+ var functionItem = document.createElement("div");
+ functionItem.className = "item";
+ functionItem._text = entry.name;
+ functionItem._arguments = (entry.arguments ? entry.arguments : "");
+ functionItem.textContent = functionItem._text + functionItem._arguments;
+ if (regExp && !regExp.test(functionItem._text)) {
+ functionItem.style.display = "none";
+ isVisible = false;
+ }
+ functionItem._line = entry.line;
+ this._itemElements.push(functionItem);
+ if (!candidateItem && isVisible)
+ candidateItem = functionItem;
+ fragment.appendChild(functionItem);
+ this._visibleElements.push(functionItem);
+ }
+ this._functionItemContainer.appendChild(fragment);
+ this._updateSelection(candidateItem);
+ },
+
+ /**
+ * @param {boolean=} isGlobal
+ */
+ _createSearchRegExp: function(query, isGlobal)
+ {
+ var trimmedQuery = query.trim();
+ var regExpString = trimmedQuery.escapeForRegExp().replace(/\\\*/g, ".*").replace(/(?!^)([A-Z])/g, "[^A-Z]*$1");
+ console.log(regExpString);
+ var isSuffix = (query.charAt(query.length - 1) === " ");
+ if (isSuffix)
+ regExpString += "$";
+ return new RegExp(regExpString, (trimmedQuery === trimmedQuery.toLowerCase() ? "i" : "") + (isGlobal ? "g" : ""));
+ },
+
+ _filterFunctions: function()
+ {
+ delete this._filterTimer;
+
+ var query = this._promptElement.value;
+ var charsAdded = this._previousInputLength < query.length;
+ this._previousInputLength = query.length;
+ if (!query.trim()) {
+ this._visibleElements = [];
+ for (var i = 0; i < this._itemElements.length; ++i) {
+ var element = this._itemElements[i];
+ element.style.display = "";
+ this._visibleElements.push(element);
+ }
+ this._updateSelection(this._functionItemContainer.firstChild);
+ return;
+ }
+
+ var regExp = this._createSearchRegExp(query);
+ var firstElement;
+ var newVisibleElements = [];
+ if (charsAdded) {
+ for (var i = 0; i < this._visibleElements.length; ++i) {
+ var element = this._visibleElements[i];
+ if (regExp.test(element._text)) {
+ if (!firstElement)
+ firstElement = element;
+ newVisibleElements.push(element);
+ } else
+ element.style.display = "none";
+ }
+ this._visibleElements = newVisibleElements;
+ this._updateSelection(firstElement);
+ return;
+ }
+
+ for (var i = 0; i < this._itemElements.length; ++i) {
+ var element = this._itemElements[i];
+ if (regExp.test(element._text)) {
+ if (!firstElement)
+ firstElement = element;
+ element.style.display = "";
+ newVisibleElements.push(element);
+ } else
+ element.style.display = "none";
+ }
+ this._visibleElements = newVisibleElements;
+ this._updateSelection(firstElement);
+ },
+
+ _selectFirstItem: function()
+ {
+ var selectedElement;
+ for (var child = this._functionItemContainer.firstChild; child; child = child.nextSibling) {
+ if (child.style.display !== "none") {
+ selectedElement = child;
+ break;
+ }
+ }
+ this._updateSelection(selectedElement);
+ },
+
+ _hide: function()
+ {
+ if (this._isHiding)
+ return;
+ this._isHiding = true;
+ if (this._filterTimer)
+ clearTimeout(this._filterTimer);
+ this._element.parentElement.removeChild(this._element);
+ WebInspector._javascript_OutlineDialog._instance = null;
+
+ WebInspector.setCurrentFocusElement(this._previousFocusElement);
+ },
+
+ _onBlur: function(event)
+ {
+ this._hide();
+ },
+
+ _onKeyDown: function(event)
+ {
+ if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Tab.code) {
+ event.preventDefault();
+ return;
+ }
+
+ function previousItem(itemElement, isPageScroll)
+ {
+ var scrollItemsLeft = isPageScroll && this._rowsPerViewport ? this._rowsPerViewport : 1;
+ var candidate = itemElement;
+ do {
+ candidate = candidate.previousSibling;
+ if (!candidate) {
+ if (isPageScroll)
+ return this._functionItemContainer.firstChild;
+ else
+ candidate = this._functionItemContainer.lastChild;
+ }
+ if (candidate.style.display === "none")
+ continue;
+ --scrollItemsLeft;
+ } while (scrollItemsLeft && candidate !== this._selectedElement);
+
+ return candidate;
+ }
+
+ function nextItem(itemElement, isPageScroll)
+ {
+ var scrollItemsLeft = isPageScroll && this._rowsPerViewport ? this._rowsPerViewport : 1;
+ var candidate = itemElement;
+ do {
+ candidate = candidate.nextSibling;
+ if (!candidate) {
+ if (isPageScroll)
+ return this._functionItemContainer.lastChild;
+ else
+ candidate = this._functionItemContainer.firstChild;
+ }
+ if (candidate.style.display === "none")
+ continue;
+ --scrollItemsLeft;
+ } while (scrollItemsLeft && candidate !== this._selectedElement);
+
+ return candidate;
+ }
+
+ var delta = 1;
+ var isPageScroll = false;
+
+ switch (event.keyCode) {
+ case WebInspector.KeyboardShortcut.Keys.Up.code:
+ case WebInspector.KeyboardShortcut.Keys.PageUp.code:
+ if (!this._selectedElement)
+ return;
+ if (event.keyCode === WebInspector.KeyboardShortcut.Keys.PageUp.code)
+ isPageScroll = true;
+
+ var candidate = previousItem.call(this, this._selectedElement, isPageScroll);
+ this._updateSelection(candidate);
+ event.preventDefault();
+ return;
+
+ case WebInspector.KeyboardShortcut.Keys.Down.code:
+ case WebInspector.KeyboardShortcut.Keys.PageDown.code:
+ if (!this._selectedElement)
+ return;
+ if (event.keyCode === WebInspector.KeyboardShortcut.Keys.PageDown.code)
+ isPageScroll = true;
+
+ var candidate = nextItem.call(this, this._selectedElement, isPageScroll);
+ this._updateSelection(candidate);
+ event.preventDefault();
+ return;
+ }
+
+ if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code)
+ this._highlightFunctionLine();
+
+ if (this._closeKeys.indexOf(event.keyCode) >= 0) {
+ this._hide();
+ event.preventDefault();
+ event.stopPropagation();
+ } else if (event.keyIdentifier !== "Shift" && event.keyIdentifier !== "Ctrl" && event.keyIdentifier !== "Meta" && event.keyIdentifier !== "Left" && event.keyIdentifier !== "Right")
+ this._scheduleFilter();
+ },
+
+ _scheduleFilter: function()
+ {
+ if (this._filterTimer)
+ return;
+ this._filterTimer = setTimeout(this._filterFunctions.bind(this), 0);
+ },
+
+ _updateSelection: function(newSelectedElement)
+ {
+ if (this._selectedElement === newSelectedElement)
+ return;
+ if (this._selectedElement)
+ this._selectedElement.removeStyleClass("selected");
+
+ this._selectedElement = newSelectedElement;
+ if (newSelectedElement) {
+ newSelectedElement.addStyleClass("selected");
+ newSelectedElement.scrollIntoViewIfNeeded(false);
+ if (!this._rowsPerViewport)
+ this._rowsPerViewport = Math.floor(this._functionItemContainer.offsetHeight / newSelectedElement.offsetHeight);
+ }
+ },
+
+ _onClick: function(event)
+ {
+ var itemElement = event.target.enclosingNodeOrSelfWithClass("item");
+ if (!itemElement)
+ return;
+ this._updateSelection(itemElement);
+ this._highlightFunctionLine();
+ this._hide();
+ },
+
+ _onMouseMove: function(event)
+ {
+ var itemElement = event.target.enclosingNodeOrSelfWithClass("item");
+ if (!itemElement)
+ return;
+ this._updateSelection(itemElement);
+ },
+
+ _highlightFunctionLine: function()
+ {
+ var lineNumber = this._selectedElement._line;
+ if (!isNaN(lineNumber) && lineNumber >= 0)
+ this._view.highlightLine(lineNumber);
+ }
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (103681 => 103682)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2011-12-26 12:39:39 UTC (rev 103682)
@@ -53,6 +53,11 @@
}
WebInspector._javascript_SourceFrame.prototype = {
+ get uiSourceCode()
+ {
+ return this._uiSourceCode;
+ },
+
// View events
willHide: function()
{
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (103681 => 103682)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-12-26 12:39:39 UTC (rev 103682)
@@ -42,6 +42,7 @@
return this.visibleView;
}
WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
+ WebInspector._javascript_OutlineDialog.install(this, viewGetter.bind(this));
this.editorToolbar = this._createEditorToolbar();
this.debugToolbar = this._createDebugToolbar();
@@ -121,6 +122,9 @@
helpSection.addKey(evaluateInConsoleShortcut.name, WebInspector.UIString("Evaluate selection in console"));
this.registerShortcut(evaluateInConsoleShortcut.key, this._evaluateSelectionInConsole.bind(this));
+ var scriptOutlineShortcut = WebInspector._javascript_OutlineDialog.createShortcut();
+ helpSection.addKey(scriptOutlineShortcut.name, WebInspector.UIString("Go to Function"));
+
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");
@@ -220,6 +224,17 @@
this._toggleBreakpointsClicked();
},
+ _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;
+ }
+ }
+ },
+
_uiSourceCodeAdded: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
@@ -518,7 +533,6 @@
delete this._initialViewSelectionProcessed;
- this.functionsSelectElement.removeChildren();
this.visibleView = null;
this.sidebarPanes.jsBreakpoints.reset();
@@ -633,6 +647,22 @@
return sourceFrame;
},
+ requestVisibleScriptOutline: function()
+ {
+ function contentCallback(mimeType, content)
+ {
+ 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
*/
@@ -1028,14 +1058,6 @@
this._filesSelectElement.addEventListener("keyup", this._filesSelectChanged.bind(this, false), false);
editorToolbar.appendChild(this._filesSelectElement);
- this.functionsSelectElement = document.createElement("select");
- this.functionsSelectElement.className = "status-bar-item";
- this.functionsSelectElement.id = "scripts-functions";
-
- // FIXME: append the functions select element to the top status bar when it
- // is implemented.
- // editorToolbar.appendChild(this.functionsSelectElement);
-
return editorToolbar;
},
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (103681 => 103682)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-12-26 12:39:39 UTC (rev 103682)
@@ -72,6 +72,7 @@
<file>InspectorView.js</file>
<file>_javascript_ContextManager.js</file>
<file>_javascript_Formatter.js</file>
+ <file>_javascript_OutlineDialog.js</file>
<file>_javascript_SourceFrame.js</file>
<file>KeyboardShortcut.js</file>
<file>MetricsSidebarPane.js</file>
@@ -164,6 +165,7 @@
<file>inspector.css</file>
<file>inspectorCommon.css</file>
<file>inspectorSyntaxHighlight.css</file>
+ <file>_javascript_OutlineDialog.css</file>
<file>networkLogView.css</file>
<file>networkPanel.css</file>
<file>panelEnablerView.css</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (103681 => 103682)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2011-12-26 12:27:47 UTC (rev 103681)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2011-12-26 12:39:39 UTC (rev 103682)
@@ -113,6 +113,7 @@
<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=""
Added: trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.css (0 => 103682)
--- trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.css (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.css 2011-12-26 12:39:39 UTC (rev 103682)
@@ -0,0 +1,55 @@
+.js-outline-dialog {
+ position: absolute;
+ top: 20%;
+ left: 20%;
+ z-index: 1900;
+ overflow: hidden;
+
+ background-color: whitesmoke;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ padding: 10px;
+ border-radius: 10px;
+ border: 1px solid gray;
+ -webkit-box-shadow: rgb(40,40,40) 0px 0px 50px;
+
+ font-size: 11px;
+ font-family: 'Lucida Grande', sans-serif;
+}
+
+.js-outline-dialog > input {
+ font-size: 11px;
+ width: 100%;
+ height: 24px;
+}
+
+.js-outline-dialog > div.progress {
+ position: absolute;
+ top: 35px;
+ left: 10px;
+ right: 10px;
+ height: 2px;
+}
+
+.js-outline-dialog > div.container {
+ position: absolute;
+ top: 38px;
+ bottom: 10px;
+ left: 10px;
+ right: 10px;
+ overflow-y: auto;
+ border: 1px solid rgb(187, 187, 187);
+ background-color: white;
+}
+
+.js-outline-dialog > .container > div.item {
+ padding: 2px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ color: rgb(105, 105, 105);
+}
+
+.js-outline-dialog > .container > div.item.selected {
+ background-color: rgb(224, 224, 224);
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.css
___________________________________________________________________
Added: svn:eol-style