diff options
Diffstat (limited to 'WebCore/inspector/front-end')
-rw-r--r-- | WebCore/inspector/front-end/Console.js | 186 | ||||
-rw-r--r-- | WebCore/inspector/front-end/DOMStorage.js | 72 | ||||
-rw-r--r-- | WebCore/inspector/front-end/DOMStorageDataGrid.js | 103 | ||||
-rw-r--r-- | WebCore/inspector/front-end/DOMStorageItemsView.js | 108 | ||||
-rw-r--r-- | WebCore/inspector/front-end/DatabaseQueryView.js | 2 | ||||
-rw-r--r-- | WebCore/inspector/front-end/DatabaseTableView.js | 20 | ||||
-rw-r--r-- | WebCore/inspector/front-end/DatabasesPanel.js | 199 | ||||
-rw-r--r-- | WebCore/inspector/front-end/Images/domStorage.png | bin | 0 -> 442 bytes | |||
-rw-r--r-- | WebCore/inspector/front-end/Images/userInputResultIcon.png | bin | 0 -> 259 bytes | |||
-rw-r--r-- | WebCore/inspector/front-end/ScriptsPanel.js | 22 | ||||
-rw-r--r-- | WebCore/inspector/front-end/SourceFrame.js | 2 | ||||
-rw-r--r-- | WebCore/inspector/front-end/WebKit.qrc | 4 | ||||
-rw-r--r-- | WebCore/inspector/front-end/inspector.css | 135 | ||||
-rw-r--r-- | WebCore/inspector/front-end/inspector.html | 3 | ||||
-rw-r--r-- | WebCore/inspector/front-end/inspector.js | 9 | ||||
-rw-r--r-- | WebCore/inspector/front-end/utilities.js | 37 |
16 files changed, 753 insertions, 149 deletions
diff --git a/WebCore/inspector/front-end/Console.js b/WebCore/inspector/front-end/Console.js index 31e466c..ba879a0 100644 --- a/WebCore/inspector/front-end/Console.js +++ b/WebCore/inspector/front-end/Console.js @@ -141,7 +141,7 @@ WebInspector.Console.prototype = { addMessage: function(msg) { - if (msg instanceof WebInspector.ConsoleMessage) { + if (msg instanceof WebInspector.ConsoleMessage && !(msg instanceof WebInspector.ConsoleCommandResult)) { msg.totalRepeatCount = msg.repeatCount; msg.repeatDelta = msg.repeatCount; @@ -446,6 +446,9 @@ WebInspector.Console.prototype = { if (!str.length) return; + var commandMessage = new WebInspector.ConsoleCommand(str); + this.addMessage(commandMessage); + var result; var exception = false; try { @@ -459,31 +462,12 @@ WebInspector.Console.prototype = { this.prompt.historyOffset = 0; this.prompt.text = ""; - var level = exception ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log; - this.addMessage(new WebInspector.ConsoleCommand(str, result, this._format(result), level)); - }, - - _mouseOverNode: function(event) - { - var anchorElement = event.target.enclosingNodeOrSelfWithNodeName("a"); - WebInspector.hoveredDOMNode = (anchorElement ? anchorElement.representedNode : null); - }, - - _mouseOutOfNode: function(event) - { - var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY); - var anchorElement = nodeUnderMouse.enclosingNodeOrSelfWithNodeName("a"); - if (!anchorElement || !anchorElement.representedNode) - WebInspector.hoveredDOMNode = null; + this.addMessage(new WebInspector.ConsoleCommandResult(result, exception, commandMessage)); }, - _format: function(output, inline) + _format: function(output, forceObjectFormat) { - var type = Object.type(output, InspectorController.inspectedWindow()); - if (type === "object") { - if (output instanceof InspectorController.inspectedWindow().Node) - type = "node"; - } + var type = (forceObjectFormat ? "object" : Object.type(output, InspectorController.inspectedWindow())); // We don't perform any special formatting on these types, so we just // pass them through the simple _formatvalue function. @@ -497,7 +481,9 @@ WebInspector.Console.prototype = { }; var formatter; - if (type in undecoratedTypes) + if (forceObjectFormat) + formatter = "_formatobject"; + else if (type in undecoratedTypes) formatter = "_formatvalue"; else { formatter = "_format" + type; @@ -509,77 +495,74 @@ WebInspector.Console.prototype = { var span = document.createElement("span"); span.addStyleClass("console-formatted-" + type); - this[formatter](output, span, inline); + this[formatter](output, span); return span; }, - _formatvalue: function(val, elem, inline) + _formatvalue: function(val, elem) { elem.appendChild(document.createTextNode(val)); }, - _formatstring: function(str, elem, inline) + _formatstring: function(str, elem) { elem.appendChild(document.createTextNode("\"" + str + "\"")); }, - _formatregexp: function(re, elem, inline) + _formatregexp: function(re, elem) { var formatted = String(re).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1); elem.appendChild(document.createTextNode(formatted)); }, - _formatarray: function(arr, elem, inline) + _formatarray: function(arr, elem) { elem.appendChild(document.createTextNode("[")); for (var i = 0; i < arr.length; ++i) { - elem.appendChild(this._format(arr[i], true)); + elem.appendChild(this._format(arr[i])); if (i < arr.length - 1) elem.appendChild(document.createTextNode(", ")); } elem.appendChild(document.createTextNode("]")); }, - _formatnode: function(node, elem, inline) + _formatnode: function(node, elem) { - var anchor = document.createElement("a"); - anchor.className = "inspectible-node"; - anchor.innerHTML = nodeTitleInfo.call(node).title; - anchor.representedNode = node; - anchor.addEventListener("mouseover", this._mouseOverNode.bind(this), false); - anchor.addEventListener("mouseout", this._mouseOutOfNode.bind(this), false); - - if (inline) - elem.appendChild(anchor); - else - elem.appendChild(new WebInspector.ObjectPropertiesSection(node, anchor, null, null, true).element); + var treeOutline = new WebInspector.ElementsTreeOutline(); + treeOutline.rootDOMNode = node; + treeOutline.element.addStyleClass("outline-disclosure"); + if (!treeOutline.children[0].hasChildren) + treeOutline.element.addStyleClass("single-node"); + elem.appendChild(treeOutline.element); }, - _formatobject: function(obj, elem, inline) + _formatobject: function(obj, elem) { - if (inline) - elem.appendChild(document.createTextNode(Object.describe(obj))); - else - elem.appendChild(new WebInspector.ObjectPropertiesSection(obj, null, null, null, true).element); + elem.appendChild(new WebInspector.ObjectPropertiesSection(obj, null, null, null, true).element); }, - _formaterror: function(obj, elem, inline) + _formaterror: function(obj, elem) { - elem.appendChild(document.createTextNode(obj.name + ": " + obj.message + " ")); + var messageElement = document.createElement("span"); + messageElement.className = "error-message"; + messageElement.textContent = obj.name + ": " + obj.message; + elem.appendChild(messageElement); if (obj.sourceURL) { var urlElement = document.createElement("a"); - urlElement.className = "console-message-url webkit-html-resource-link"; + urlElement.className = "webkit-html-resource-link"; urlElement.href = obj.sourceURL; urlElement.lineNumber = obj.line; urlElement.preferredPanel = "scripts"; if (obj.line > 0) - urlElement.textContent = WebInspector.UIString("%s (line %d)", obj.sourceURL, obj.line); + urlElement.textContent = WebInspector.displayNameForURL(obj.sourceURL) + ":" + obj.line; else - urlElement.textContent = obj.sourceURL; + urlElement.textContent = WebInspector.displayNameForURL(obj.sourceURL); + elem.appendChild(document.createTextNode(" (")); elem.appendChild(urlElement); + elem.appendChild(document.createTextNode(")")); } }, } @@ -596,18 +579,6 @@ WebInspector.ConsoleMessage = function(source, level, line, url, groupLevel, rep this.repeatCount = repeatCount; switch (this.level) { - case WebInspector.ConsoleMessage.MessageLevel.Object: - var propertiesSection = new WebInspector.ObjectPropertiesSection(arguments[6], null, null, null, true); - propertiesSection.element.addStyleClass("console-message"); - this.propertiesSection = propertiesSection; - break; - case WebInspector.ConsoleMessage.MessageLevel.Node: - var node = arguments[6]; - if (!(node instanceof InspectorController.inspectedWindow().Node)) - return; - this.elementsTreeOutline = new WebInspector.ElementsTreeOutline(); - this.elementsTreeOutline.rootDOMNode = node; - break; case WebInspector.ConsoleMessage.MessageLevel.Trace: var span = document.createElement("span"); span.addStyleClass("console-formatted-trace"); @@ -618,14 +589,16 @@ WebInspector.ConsoleMessage = function(source, level, line, url, groupLevel, rep span.appendChild(document.createTextNode(funcNames.join("\n"))); this.formattedMessage = span; break; + case WebInspector.ConsoleMessage.MessageLevel.Object: + this.formattedMessage = this._format(["%O", arguments[6]]); + break; default: - // The formatedMessage property is used for the rich and interactive console. this.formattedMessage = this._format(Array.prototype.slice.call(arguments, 6)); - - // This is used for inline message bubbles in SourceFrames, or other plain-text representations. - this.message = this.formattedMessage.textContent; break; } + + // This is used for inline message bubbles in SourceFrames, or other plain-text representations. + this.message = this.formattedMessage.textContent; } WebInspector.ConsoleMessage.prototype = { @@ -643,6 +616,11 @@ WebInspector.ConsoleMessage.prototype = { function formatForConsole(obj) { + return WebInspector.console._format(obj); + } + + function formatAsObjectForConsole(obj) + { return WebInspector.console._format(obj, true); } @@ -655,6 +633,8 @@ WebInspector.ConsoleMessage.prototype = { formatters.o = formatForConsole; // Firebug allows both %i and %d for formatting integers. formatters.i = formatters.d; + // Support %O to force object formating, instead of the type-based %o formatting. + formatters.O = formatAsObjectForConsole; function append(a, b) { @@ -675,10 +655,9 @@ WebInspector.ConsoleMessage.prototype = { for (var i = 0; i < parameters.length; ++i) { if (typeof parameters[i] === "string") formattedResult.appendChild(WebInspector.linkifyStringAsFragment(parameters[i])); - else if (parameters.length === 1) - formattedResult.appendChild(WebInspector.console._format(parameters[0])); else formattedResult.appendChild(formatForConsole(parameters[i])); + if (i < parameters.length - 1) formattedResult.appendChild(document.createTextNode(" ")); } @@ -758,7 +737,7 @@ WebInspector.ConsoleMessage.prototype = { urlElement.preferredPanel = "scripts"; if (this.line > 0) - urlElement.textContent = WebInspector.UIString("%s (line %d)", WebInspector.displayNameForURL(this.url), this.line); + urlElement.textContent = WebInspector.displayNameForURL(this.url) + ":" + this.line; else urlElement.textContent = WebInspector.displayNameForURL(this.url); @@ -814,14 +793,20 @@ WebInspector.ConsoleMessage.prototype = { case WebInspector.ConsoleMessage.MessageLevel.Object: levelString = "Object"; break; - case WebInspector.ConsoleMessage.MessageLevel.GroupTitle: - levelString = "GroupTitle"; + case WebInspector.ConsoleMessage.MessageLevel.Trace: + levelString = "Trace"; + break; + case WebInspector.ConsoleMessage.MessageLevel.StartGroup: + levelString = "Start Group"; + break; + case WebInspector.ConsoleMessage.MessageLevel.EndGroup: + levelString = "End Group"; break; } return sourceString + " " + levelString + ": " + this.formattedMessage.textContent + "\n" + this.url + " line " + this.line; }, - + isEqual: function(msg, disreguardGroup) { if (!msg) @@ -853,17 +838,14 @@ WebInspector.ConsoleMessage.MessageLevel = { Warning: 2, Error: 3, Object: 4, - Node: 5, - Trace: 6, - StartGroup: 7, - EndGroup: 8 + Trace: 5, + StartGroup: 6, + EndGroup: 7 } -WebInspector.ConsoleCommand = function(command, result, formattedResultElement, level) +WebInspector.ConsoleCommand = function(command) { this.command = command; - this.formattedResultElement = formattedResultElement; - this.level = level; } WebInspector.ConsoleCommand.prototype = { @@ -878,30 +860,33 @@ WebInspector.ConsoleCommand.prototype = { commandTextElement.textContent = this.command; element.appendChild(commandTextElement); - var resultElement = document.createElement("div"); - resultElement.className = "console-message"; - element.appendChild(resultElement); + return element; + } +} - switch (this.level) { - case WebInspector.ConsoleMessage.MessageLevel.Log: - resultElement.addStyleClass("console-log-level"); - break; - case WebInspector.ConsoleMessage.MessageLevel.Warning: - resultElement.addStyleClass("console-warning-level"); - break; - case WebInspector.ConsoleMessage.MessageLevel.Error: - resultElement.addStyleClass("console-error-level"); - } +WebInspector.ConsoleCommandResult = function(result, exception, originatingCommand) +{ + var level = (exception ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); + var message = (exception ? String(result) : result); + var line = (exception ? result.line : -1); + var url = (exception ? result.sourceURL : null); + + WebInspector.ConsoleMessage.call(this, WebInspector.ConsoleMessage.MessageSource.JS, level, line, url, null, 1, message); - var resultTextElement = document.createElement("span"); - resultTextElement.className = "console-message-text"; - resultTextElement.appendChild(this.formattedResultElement); - resultElement.appendChild(resultTextElement); + this.originatingCommand = originatingCommand; +} +WebInspector.ConsoleCommandResult.prototype = { + toMessageElement: function() + { + var element = WebInspector.ConsoleMessage.prototype.toMessageElement.call(this); + element.addStyleClass("console-user-command-result"); return element; } } +WebInspector.ConsoleCommandResult.prototype.__proto__ = WebInspector.ConsoleMessage.prototype; + WebInspector.ConsoleGroup = function(parentGroup, level) { this.parentGroup = parentGroup; @@ -928,8 +913,11 @@ WebInspector.ConsoleGroup.prototype = { element.addEventListener("click", this._titleClicked.bind(this), true); } else this.messagesElement.appendChild(element); + + if (element.previousSibling && msg.originatingCommand && element.previousSibling.command === msg.originatingCommand) + element.previousSibling.addStyleClass("console-adjacent-user-command-result"); }, - + _titleClicked: function(event) { var groupTitleElement = event.target.enclosingNodeOrSelfWithClass("console-group-title-level"); diff --git a/WebCore/inspector/front-end/DOMStorage.js b/WebCore/inspector/front-end/DOMStorage.js new file mode 100644 index 0000000..5207b69 --- /dev/null +++ b/WebCore/inspector/front-end/DOMStorage.js @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2008 Nokia 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: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 "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 APPLE OR ITS 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. + */ + +WebInspector.DOMStorage = function(domStorage, domain, isLocalStorage) +{ + this.domStorage = domStorage; + this.domain = domain; + this.isLocalStorage = isLocalStorage; +} + +WebInspector.DOMStorage.prototype = { + get domStorage() + { + return this._domStorage; + }, + + set domStorage(x) + { + if (this._domStorage === x) + return; + this._domStorage = x; + }, + + get domain() + { + return this._domain; + }, + + set domain(x) + { + if (this._domain === x) + return; + this._domain = x; + }, + + get isLocalStorage() + { + return this._isLocalStorage; + }, + + set isLocalStorage(x) + { + if (this._isLocalStorage === x) + return; + this._isLocalStorage = x; + } +} diff --git a/WebCore/inspector/front-end/DOMStorageDataGrid.js b/WebCore/inspector/front-end/DOMStorageDataGrid.js new file mode 100644 index 0000000..9946415 --- /dev/null +++ b/WebCore/inspector/front-end/DOMStorageDataGrid.js @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2009 Nokia 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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. + */ + +WebInspector.DOMStorageDataGrid = function(columns) +{ + WebInspector.DataGrid.call(this, columns); + this.dataTableBody.addEventListener("dblclick", this._ondblclick.bind(this), false); +} + +WebInspector.DOMStorageDataGrid.prototype = { + _ondblclick: function(event) + { + if (this._editing) + return; + if (this._editingNode) + return; + this._startEditing(event); + }, + + _startEditing: function(event) + { + var element = event.target.enclosingNodeOrSelfWithNodeName("td"); + if (!element) + return; + this._editingNode = this.dataGridNodeFromEvent(event); + if (!this._editingNode) + return; + this._editing = true; + + WebInspector.startEditing(element, this._editingCommitted.bind(this), this._editingCancelled.bind(this), element.textContent); + window.getSelection().setBaseAndExtent(element, 0, element, 1); + }, + + _editingCommitted: function(element, newText) + { + if (element.hasStyleClass("0-column")) + columnIdentifier = 0; + else + columnIdentifier = 1; + textBeforeEditing = this._editingNode.data[columnIdentifier]; + if (textBeforeEditing == newText) { + this._editingCancelled(element); + return; + } + + var domStorage = WebInspector.panels.databases.visibleView.domStorage.domStorage; + if (domStorage) { + if (columnIdentifier == 0) { + if (domStorage.getItem(newText) != null) { + element.textContent = this._editingNode.data[0]; + this._editingCancelled(element); + return; + } + domStorage.removeItem(this._editingNode.data[0]); + domStorage.setItem(newText, this._editingNode.data[1]); + this._editingNode.data[0] = newText; + } else { + domStorage.setItem(this._editingNode.data[0], newText); + this._editingNode.data[1] = newText; + } + } + + this._editingCancelled(element); + }, + + _editingCancelled: function(element, context) + { + delete this._editing; + this._editingNode = null; + }, + + deleteSelectedRow: function() + { + var node = this.selectedNode; + var domStorage = WebInspector.panels.databases.visibleView.domStorage.domStorage; + if (node && domStorage) + domStorage.removeItem(node.data[0]); + } +} + +WebInspector.DOMStorageDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype; diff --git a/WebCore/inspector/front-end/DOMStorageItemsView.js b/WebCore/inspector/front-end/DOMStorageItemsView.js new file mode 100644 index 0000000..912573e --- /dev/null +++ b/WebCore/inspector/front-end/DOMStorageItemsView.js @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2008 Nokia 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED ``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 APPLE INC. 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. + */ + +WebInspector.DOMStorageItemsView = function(domStorage) +{ + WebInspector.View.call(this); + + this.domStorage = domStorage; + + this.element.addStyleClass("storage-view"); + this.element.addStyleClass("table"); + + this.deleteButton = document.createElement("button"); + this.deleteButton.title = WebInspector.UIString("Delete"); + this.deleteButton.className = "delete-storage-status-bar-item status-bar-item hidden"; + this.deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false); + + this.refreshButton = document.createElement("button"); + this.refreshButton.title = WebInspector.UIString("Refresh"); + this.refreshButton.className = "refresh-storage-status-bar-item status-bar-item"; + this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false); +} + +WebInspector.DOMStorageItemsView.prototype = { + get statusBarItems() + { + return [this.refreshButton, this.deleteButton]; + }, + + show: function(parentElement) + { + WebInspector.View.prototype.show.call(this, parentElement); + this.update(); + }, + + hide: function() + { + WebInspector.View.prototype.hide.call(this); + this.deleteButton.addStyleClass("hidden"); + }, + + update: function() + { + this.element.removeChildren(); + var hasDOMStorage = this.domStorage; + if (hasDOMStorage) + hasDOMStorage = this.domStorage.domStorage; + + if (hasDOMStorage) { + var dataGrid = WebInspector.panels.databases.dataGridForDOMStorage(this.domStorage.domStorage); + if (!dataGrid) + hasDOMStorage = 0; + else { + this._dataGrid = dataGrid; + this.element.appendChild(dataGrid.element); + this.deleteButton.removeStyleClass("hidden"); + } + } + + if (!hasDOMStorage) { + var emptyMsgElement = document.createElement("div"); + emptyMsgElement.className = "storage-table-empty"; + if (this.domStorage) + emptyMsgElement.textContent = WebInspector.UIString("This storage is empty."); + this.element.appendChild(emptyMsgElement); + this._dataGrid = null; + this.deleteButton.addStyleClass("hidden"); + } + }, + + _deleteButtonClicked: function(event) + { + if (this._dataGrid) { + this._dataGrid.deleteSelectedRow(); + + this.show(); + } + }, + + _refreshButtonClicked: function(event) + { + this.update(); + } +} + +WebInspector.DOMStorageItemsView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/WebCore/inspector/front-end/DatabaseQueryView.js b/WebCore/inspector/front-end/DatabaseQueryView.js index 6a91625..122707f 100644 --- a/WebCore/inspector/front-end/DatabaseQueryView.js +++ b/WebCore/inspector/front-end/DatabaseQueryView.js @@ -29,7 +29,7 @@ WebInspector.DatabaseQueryView = function(database) this.database = database; - this.element.addStyleClass("database-view"); + this.element.addStyleClass("storage-view"); this.element.addStyleClass("query"); this.element.tabIndex = 0; diff --git a/WebCore/inspector/front-end/DatabaseTableView.js b/WebCore/inspector/front-end/DatabaseTableView.js index 2e72240..bbca9d0 100644 --- a/WebCore/inspector/front-end/DatabaseTableView.js +++ b/WebCore/inspector/front-end/DatabaseTableView.js @@ -30,8 +30,13 @@ WebInspector.DatabaseTableView = function(database, tableName) this.database = database; this.tableName = tableName; - this.element.addStyleClass("database-view"); + this.element.addStyleClass("storage-view"); this.element.addStyleClass("table"); + + this.refreshButton = document.createElement("button"); + this.refreshButton.title = WebInspector.UIString("Refresh"); + this.refreshButton.className = "refresh-storage-status-bar-item status-bar-item"; + this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false); } WebInspector.DatabaseTableView.prototype = { @@ -41,6 +46,11 @@ WebInspector.DatabaseTableView.prototype = { this.update(); }, + get statusBarItems() + { + return [this.refreshButton]; + }, + update: function() { function queryTransaction(tx) @@ -58,7 +68,7 @@ WebInspector.DatabaseTableView.prototype = { var dataGrid = WebInspector.panels.databases.dataGridForResult(result); if (!dataGrid) { var emptyMsgElement = document.createElement("div"); - emptyMsgElement.className = "database-table-empty"; + emptyMsgElement.className = "storage-table-empty"; emptyMsgElement.textContent = WebInspector.UIString("The ā%sā\ntable is empty.", this.tableName); this.element.appendChild(emptyMsgElement); return; @@ -72,11 +82,15 @@ WebInspector.DatabaseTableView.prototype = { this.element.removeChildren(); var errorMsgElement = document.createElement("div"); - errorMsgElement.className = "database-table-error"; + errorMsgElement.className = "storage-table-error"; errorMsgElement.textContent = WebInspector.UIString("An error occurred trying to\nread the ā%sā table.", this.tableName); this.element.appendChild(errorMsgElement); }, + _refreshButtonClicked: function(event) + { + this.update(); + } } WebInspector.DatabaseTableView.prototype.__proto__ = WebInspector.View.prototype; diff --git a/WebCore/inspector/front-end/DatabasesPanel.js b/WebCore/inspector/front-end/DatabasesPanel.js index df5bbb3..4644b3b 100644 --- a/WebCore/inspector/front-end/DatabasesPanel.js +++ b/WebCore/inspector/front-end/DatabasesPanel.js @@ -46,9 +46,24 @@ WebInspector.DatabasesPanel = function(database) this.sidebarTree = new TreeOutline(this.sidebarTreeElement); - this.databaseViews = document.createElement("div"); - this.databaseViews.id = "database-views"; - this.element.appendChild(this.databaseViews); + this.databasesListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("DATABASES"), {}, true); + this.sidebarTree.appendChild(this.databasesListTreeElement); + this.databasesListTreeElement.expand(); + + this.localStorageListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("LOCAL STORAGE"), {}, true); + this.sidebarTree.appendChild(this.localStorageListTreeElement); + this.localStorageListTreeElement.expand(); + + this.sessionStorageListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("SESSION STORAGE"), {}, true); + this.sidebarTree.appendChild(this.sessionStorageListTreeElement); + this.sessionStorageListTreeElement.expand(); + + this.storageViews = document.createElement("div"); + this.storageViews.id = "storage-views"; + this.element.appendChild(this.storageViews); + + this.storageViewStatusBarItemsContainer = document.createElement("div"); + this.storageViewStatusBarItemsContainer.id = "storage-view-status-bar-items"; this.reset(); } @@ -61,6 +76,11 @@ WebInspector.DatabasesPanel.prototype = { return WebInspector.UIString("Databases"); }, + get statusBarItems() + { + return [this.storageViewStatusBarItemsContainer]; + }, + show: function() { WebInspector.Panel.prototype.show.call(this); @@ -81,8 +101,23 @@ WebInspector.DatabasesPanel.prototype = { this._databases = []; - this.sidebarTree.removeChildren(); - this.databaseViews.removeChildren(); + if (this._domStorage) { + var domStorageLength = this._domStorage.length; + for (var i = 0; i < domStorageLength; ++i) { + var domStorage = this._domStorage[i]; + + delete domStorage._domStorageView; + } + } + + this._domStorage = []; + + this.databasesListTreeElement.removeChildren(); + this.localStorageListTreeElement.removeChildren(); + this.sessionStorageListTreeElement.removeChildren(); + this.storageViews.removeChildren(); + + this.storageViewStatusBarItemsContainer.removeChildren(); }, handleKeyEvent: function(event) @@ -96,8 +131,18 @@ WebInspector.DatabasesPanel.prototype = { var databaseTreeElement = new WebInspector.DatabaseSidebarTreeElement(database); database._databasesTreeElement = databaseTreeElement; + this.databasesListTreeElement.appendChild(databaseTreeElement); + }, - this.sidebarTree.appendChild(databaseTreeElement); + addDOMStorage: function(domStorage) + { + this._domStorage.push(domStorage); + var domStorageTreeElement = new WebInspector.DOMStorageSidebarTreeElement(domStorage); + domStorage._domStorageTreeElement = domStorageTreeElement; + if (domStorage.isLocalStorage) + this.localStorageListTreeElement.appendChild(domStorageTreeElement); + else + this.sessionStorageListTreeElement.appendChild(domStorageTreeElement); }, showDatabase: function(database, tableName) @@ -105,8 +150,8 @@ WebInspector.DatabasesPanel.prototype = { if (!database) return; - if (this.visibleDatabaseView) - this.visibleDatabaseView.hide(); + if (this.visibleView) + this.visibleView.hide(); var view; if (tableName) { @@ -125,16 +170,46 @@ WebInspector.DatabasesPanel.prototype = { } } - view.show(this.databaseViews); + view.show(this.storageViews); + + this.visibleView = view; - this.visibleDatabaseView = view; + this.storageViewStatusBarItemsContainer.removeChildren(); + var statusBarItems = view.statusBarItems; + for (var i = 0; i < statusBarItems.length; ++i) + this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]); + }, + + showDOMStorage: function(domStorage) + { + if (!domStorage) + return; + + if (this.visibleView) + this.visibleView.hide(); + + var view; + view = domStorage._domStorageView; + if (!view) { + view = new WebInspector.DOMStorageItemsView(domStorage); + domStorage._domStorageView = view; + } + + view.show(this.storageViews); + + this.visibleView = view; + + this.storageViewStatusBarItemsContainer.removeChildren(); + var statusBarItems = view.statusBarItems; + for (var i = 0; i < statusBarItems.length; ++i) + this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]); }, closeVisibleView: function() { - if (this.visibleDatabaseView) - this.visibleDatabaseView.hide(); - delete this.visibleDatabaseView; + if (this.visibleView) + this.visibleView.hide(); + delete this.visibleView; }, updateDatabaseTables: function(database) @@ -155,7 +230,7 @@ WebInspector.DatabasesPanel.prototype = { for (var tableName in database._tableViews) { if (!(tableName in tableNamesHash)) { - if (this.visibleDatabaseView === database._tableViews[tableName]) + if (this.visibleView === database._tableViews[tableName]) this.closeVisibleView(); delete database._tableViews[tableName]; } @@ -241,6 +316,60 @@ WebInspector.DatabasesPanel.prototype = { return dataGrid; }, + dataGridForDOMStorage: function(domStorage) + { + if (!domStorage.length) + return null; + + var columns = {}; + columns[0] = {}; + columns[1] = {}; + columns[0].title = WebInspector.UIString("Key"); + columns[0].width = columns[0].title.length; + columns[1].title = WebInspector.UIString("Value"); + columns[1].width = columns[0].title.length; + + var nodes = []; + + var length = domStorage.length; + for (index = 0; index < domStorage.length; index++) { + var data = {}; + + var key = String(domStorage.key(index)); + data[0] = key; + if (key.length > columns[0].width) + columns[0].width = key.length; + + var value = String(domStorage.getItem(key)); + data[1] = value; + if (value.length > columns[1].width) + columns[1].width = value.length; + var node = new WebInspector.DataGridNode(data, false); + node.selectable = true; + nodes.push(node); + } + + var totalColumnWidths = columns[0].width + columns[1].width; + width = Math.round((columns[0].width * 100) / totalColumnWidths); + const minimumPrecent = 10; + if (width < minimumPrecent) + width = minimumPrecent; + if (width > 100 - minimumPrecent) + width = 100 - minimumPrecent; + columns[0].width = width; + columns[1].width = 100 - width; + columns[0].width += "%"; + columns[1].width += "%"; + + var dataGrid = new WebInspector.DOMStorageDataGrid(columns); + var length = nodes.length; + for (var i = 0; i < length; ++i) + dataGrid.appendChild(nodes[i]); + if (length > 0) + nodes[0].selected = true; + return dataGrid; + }, + _startSidebarDragging: function(event) { WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize"); @@ -277,7 +406,8 @@ WebInspector.DatabasesPanel.prototype = { this._currentSidebarWidth = width; this.sidebarElement.style.width = width + "px"; - this.databaseViews.style.left = width + "px"; + this.storageViews.style.left = width + "px"; + this.storageViewStatusBarItemsContainer.style.left = width + "px"; this.sidebarResizeElement.style.left = (width - 3) + "px"; } } @@ -355,3 +485,42 @@ WebInspector.SidebarDatabaseTableTreeElement.prototype = { } WebInspector.SidebarDatabaseTableTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + +WebInspector.DOMStorageSidebarTreeElement = function(domStorage) +{ + + this.domStorage = domStorage; + + WebInspector.SidebarTreeElement.call(this, "domstorage-sidebar-tree-item", domStorage, "", null, false); + + this.refreshTitles(); +} + +WebInspector.DOMStorageSidebarTreeElement.prototype = { + onselect: function() + { + WebInspector.panels.databases.showDOMStorage(this.domStorage); + }, + + get mainTitle() + { + return this.domStorage.domain; + }, + + set mainTitle(x) + { + // Do nothing. + }, + + get subtitle() + { + return ""; //this.database.displayDomain; + }, + + set subtitle(x) + { + // Do nothing. + } +} + +WebInspector.DOMStorageSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; diff --git a/WebCore/inspector/front-end/Images/domStorage.png b/WebCore/inspector/front-end/Images/domStorage.png Binary files differnew file mode 100644 index 0000000..028550c --- /dev/null +++ b/WebCore/inspector/front-end/Images/domStorage.png diff --git a/WebCore/inspector/front-end/Images/userInputResultIcon.png b/WebCore/inspector/front-end/Images/userInputResultIcon.png Binary files differnew file mode 100644 index 0000000..794a5ca --- /dev/null +++ b/WebCore/inspector/front-end/Images/userInputResultIcon.png diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js index 38a6a96..2792834 100644 --- a/WebCore/inspector/front-end/ScriptsPanel.js +++ b/WebCore/inspector/front-end/ScriptsPanel.js @@ -569,11 +569,29 @@ WebInspector.ScriptsPanel.prototype = { var select = this.filesSelectElement; - // FIXME: Append in some meaningful order. var option = document.createElement("option"); option.representedObject = (script.resource || script); option.text = (script.sourceURL ? WebInspector.displayNameForURL(script.sourceURL) : WebInspector.UIString("(program)")); - select.appendChild(option); + + var insertionIndex = -1; + if (select.childNodes) { + insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, function(a, b) { + a = a.text.toLowerCase(); + b = b.text.toLowerCase(); + + if (a < b) + return -1; + else if (a > b) + return 1; + + return 0; + }); + } + + if (insertionIndex < 0) + select.appendChild(option); + else + select.insertBefore(option, select.childNodes.item(insertionIndex)); script.filesSelectOption = option; diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js index 8d6d6d3..26c0626 100644 --- a/WebCore/inspector/front-end/SourceFrame.js +++ b/WebCore/inspector/front-end/SourceFrame.js @@ -225,8 +225,10 @@ WebInspector.SourceFrame.prototype = { this.element.contentWindow.Element.prototype.addStyleClass = Element.prototype.addStyleClass; this.element.contentWindow.Element.prototype.removeStyleClass = Element.prototype.removeStyleClass; + this.element.contentWindow.Element.prototype.removeMatchingStyleClasses = Element.prototype.removeMatchingStyleClasses; this.element.contentWindow.Element.prototype.hasStyleClass = Element.prototype.hasStyleClass; this.element.contentWindow.Node.prototype.enclosingNodeOrSelfWithNodeName = Node.prototype.enclosingNodeOrSelfWithNodeName; + this.element.contentWindow.Node.prototype.enclosingNodeOrSelfWithNodeNameInArray = Node.prototype.enclosingNodeOrSelfWithNodeNameInArray; this._addExistingMessagesToSource(); this._addExistingBreakpointsToSource(); diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc index 52a8578..997d4a7 100644 --- a/WebCore/inspector/front-end/WebKit.qrc +++ b/WebCore/inspector/front-end/WebKit.qrc @@ -10,6 +10,9 @@ <file>DatabasesPanel.js</file> <file>DatabaseTableView.js</file> <file>DataGrid.js</file> + <file>DOMStorage.js</file> + <file>DOMStorageDataGrid.js</file> + <file>DOMStorageItemsView.js</file> <file>ElementsPanel.js</file> <file>ElementsTreeOutline.js</file> <file>FontView.js</file> @@ -66,6 +69,7 @@ <file>Images/disclosureTriangleSmallRightDownWhite.png</file> <file>Images/disclosureTriangleSmallRightWhite.png</file> <file>Images/dockButtons.png</file> + <file>Images/domStorage.png</file> <file>Images/elementsIcon.png</file> <file>Images/enableButtons.png</file> <file>Images/errorIcon.png</file> diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css index 7e3c224..082955e 100644 --- a/WebCore/inspector/front-end/inspector.css +++ b/WebCore/inspector/front-end/inspector.css @@ -439,6 +439,7 @@ body.console-visible #console { #console-messages { position: absolute; + z-index: 0; top: 0; left: 0; right: 0; @@ -463,6 +464,10 @@ body.console-visible #console { background-image: url(Images/userInputIcon.png); } +.console-user-command-result.console-log-level::before { + background-image: url(Images/userInputResultIcon.png); +} + .console-message, .console-user-command { position: relative; border-bottom: 1px solid rgb(240, 240, 240); @@ -470,6 +475,14 @@ body.console-visible #console { min-height: 16px; } +.console-adjacent-user-command-result { + border-bottom: none; +} + +.console-adjacent-user-command-result + .console-user-command-result.console-log-level::before { + background-image: none; +} + .console-message::before, .console-user-command::before, #console-prompt::before, .console-group-title-level::before { position: absolute; display: block; @@ -561,35 +574,34 @@ body.console-visible #console { color: rgb(0, 128, 255); } -.console-message-url { - color: rgb(33%, 33%, 33%) !important; +#console-messages a { + color: rgb(33%, 33%, 33%); cursor: pointer; - float: right; } -.console-message-url:hover { +#console-messages a:hover { color: rgb(15%, 15%, 15%); } -.console-message-url:hover::after { - opacity: 1; +.console-message-url { + float: right; } .console-group-messages .section { - margin: 0; + margin: 0 0 0 12px !important; } .console-group-messages .section .header { padding: 0 8px 0 0; background-image: none; border: none; - min-height: 16px; + min-height: 0; } .console-group-messages .section .header::before { position: absolute; top: 1px; - left: 12px; + left: 1px; width: 8px; height: 8px; content: url(Images/treeRightTriangleBlack.png); @@ -601,6 +613,21 @@ body.console-visible #console { .console-group-messages .section .header .title { color: black; + font-weight: normal; +} + +.console-group-messages .section .properties li .info { + padding-top: 0; + padding-bottom: 0; + color: rgb(60%, 60%, 60%); +} + +.console-group-messages .outline-disclosure { + padding-left: 0; +} + +.console-group-messages .outline-disclosure > ol { + padding: 0 0 0 12px !important; } .console-group-messages .outline-disclosure, .console-group-messages .outline-disclosure ol { @@ -608,33 +635,39 @@ body.console-visible #console { line-height: 1em; } -.console-group-messages .outline-disclosure li { - padding-top: 2px; - padding-bottom: 2px; +.console-group-messages .outline-disclosure.single-node li { + padding-left: 2px; } .console-group-messages .outline-disclosure li .selection { - z-index: 0; - margin-top: -1px; + margin-left: -6px; + margin-right: -6px; +} + +.console-formatted-object, .console-formatted-node { + position: relative; + display: inline-block; + vertical-align: top; } .console-formatted-object .section, .console-formatted-node .section { position: static; } +.console-formatted-object .properties, .console-formatted-node .properties { + padding-left: 0 !important; +} + +.error-message { + color: red; +} + .auto-complete-text { color: rgb(128, 128, 128); -webkit-user-select: none; -webkit-user-modify: read-only; } -.inspectible-node:hover { - background-color: rgba(56, 121, 217, 0.1); - -webkit-border-radius: 5px; - padding: 0 5px 1px; - margin: 0 -5px -1px; -} - .panel { display: none; overflow: hidden; @@ -1532,7 +1565,11 @@ body.inactive .sidebar { content: url(Images/databaseTable.png); } -#database-views { +.domstorage-sidebar-tree-item .icon { + content: url(Images/domStorage.png); +} + +#storage-views { position: absolute; top: 0; right: 0; @@ -1540,7 +1577,7 @@ body.inactive .sidebar { bottom: 0; } -.database-view { +.storage-view { display: none; overflow: hidden; position: absolute; @@ -1550,20 +1587,20 @@ body.inactive .sidebar { bottom: 0; } -.database-view.visible { +.storage-view.visible { display: block; } -.database-view.table { +.storage-view.table { overflow: hidden; } -.database-view.table .data-grid { +.storage-view.table .data-grid { border: none; height: 100%; } -.database-view.table .database-table-empty, .database-view.table .database-table-error { +.storage-view.table .storage-table-empty, .storage-view.table .storage-table-error { position: absolute; top: 0; bottom: 25%; @@ -1581,7 +1618,7 @@ body.inactive .sidebar { white-space: pre-wrap; } -.database-view.table .database-table-error { +.storage-view.table .storage-table-error { color: rgb(66%, 33%, 33%); } @@ -1773,7 +1810,7 @@ body.inactive .data-grid th.sort-ascending, body.inactive .data-grid th.sort-des text-indent: 10px; } -.database-view.query { +.storage-view.query { font-size: 10px; font-family: Monaco, Lucida Console, monospace; padding: 2px 0; @@ -2498,6 +2535,10 @@ button.enable-toggle-status-bar-item.toggled-on:active { padding-left: 37px; } +.sidebar-tree > .children > .children > .sidebar-tree-item { + padding-left: 37px; +} + .sidebar-tree.hide-disclosure-buttons > .children { display: none; } @@ -2994,3 +3035,39 @@ body.inactive .sidebar-tree-item.selected .bubble.search-matches { .reset-profile-status-bar-item:active { background-position: 32px 0; } + +.delete-storage-status-bar-item { + background-image: url(Images/excludeButtons.png) !important; +} + +.delete-storage-status-bar-item:active { + background-position: 32px 0; +} + +#storage-view-status-bar-items { + position: absolute; + top: 0; + bottom: 0; + left: 200px; + overflow: hidden; + border-left: 1px solid rgb(184, 184, 184); + margin-left: -1px; +} + +.refresh-storage-status-bar-item { + background-image: url(Images/reloadButtons.png) !important; +} + +.refresh-storage-status-bar-item:active { + background-position: 32px 0; +} + +#storage-view-status-bar-items { + position: absolute; + top: 0; + bottom: 0; + left: 200px; + overflow: hidden; + border-left: 1px solid rgb(184, 184, 184); + margin-left: -1px; +} diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html index cb38886..77d720b 100644 --- a/WebCore/inspector/front-end/inspector.html +++ b/WebCore/inspector/front-end/inspector.html @@ -41,7 +41,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="Resource.js"></script> <script type="text/javascript" src="ResourceCategory.js"></script> <script type="text/javascript" src="Database.js"></script> + <script type="text/javascript" src="DOMStorage.js"></script> + <script type="text/javascript" src="DOMStorageItemsView.js"></script> <script type="text/javascript" src="DataGrid.js"></script> + <script type="text/javascript" src="DOMStorageDataGrid.js"></script> <script type="text/javascript" src="Script.js"></script> <script type="text/javascript" src="Breakpoint.js"></script> <script type="text/javascript" src="SidebarPane.js"></script> diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js index 07ae7db..90ffa2b 100644 --- a/WebCore/inspector/front-end/inspector.js +++ b/WebCore/inspector/front-end/inspector.js @@ -287,10 +287,14 @@ WebInspector.loaded = function() databases: new WebInspector.DatabasesPanel() }; + var hiddenPanels = (InspectorController.hiddenPanels() || "").split(','); + var toolbarElement = document.getElementById("toolbar"); var previousToolbarItem = toolbarElement.children[0]; for (var panelName in this.panels) { + if (hiddenPanels.indexOf(panelName) !== -1) + continue; var panel = this.panels[panelName]; var panelToolbarItem = panel.toolbarItem; panelToolbarItem.addEventListener("click", this._toolbarItemClicked.bind(this)); @@ -795,6 +799,11 @@ WebInspector.addDatabase = function(database) this.panels.databases.addDatabase(database); } +WebInspector.addDOMStorage = function(domStorage) +{ + this.panels.databases.addDOMStorage(domStorage); +} + WebInspector.debuggerWasEnabled = function() { this.panels.scripts.debuggerWasEnabled(); diff --git a/WebCore/inspector/front-end/utilities.js b/WebCore/inspector/front-end/utilities.js index 8f86504..7b0a20b 100644 --- a/WebCore/inspector/front-end/utilities.js +++ b/WebCore/inspector/front-end/utilities.js @@ -37,6 +37,8 @@ Object.type = function(obj, win) win = win || window; + if (obj instanceof win.Node) + return "node"; if (obj instanceof win.String) return "string"; if (obj instanceof win.Array) @@ -70,6 +72,7 @@ Object.describe = function(obj, abbreviated) switch (type1) { case "object": + case "node": return type2; case "array": return "[" + obj.toString() + "]"; @@ -937,6 +940,40 @@ Array.prototype.remove = function(value, onlyFirst) } } +function insertionIndexForObjectInListSortedByFunction(anObject, aList, aFunction) +{ + // indexOf returns (-lowerBound - 1). Taking (-result - 1) works out to lowerBound. + return (-indexOfObjectInListSortedByFunction(anObject, aList, aFunction) - 1); +} + +function indexOfObjectInListSortedByFunction(anObject, aList, aFunction) +{ + var first = 0; + var last = aList.length - 1; + var floor = Math.floor; + var mid, c; + + while (first <= last) { + mid = floor((first + last) / 2); + c = aFunction(anObject, aList[mid]); + + if (c > 0) + first = mid + 1; + else if (c < 0) + last = mid - 1; + else { + //we return the first occurance of an item in the list. + while (mid > 0 && aFunction(anObject, aList[mid - 1]) === 0) + mid--; + return mid; + } + } + + // By returning 1 less than the negative lower search bound, we can reuse this function + // for both indexOf and insertionIndexFor, with some simple arithmetic. + return (-first - 1); +} + String.sprintf = function(format) { return String.vsprintf(format, Array.prototype.slice.call(arguments, 1)); |