diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-10-22 17:50:52 (GMT) |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-10-22 18:34:20 (GMT) |
commit | 57f1983c164bc8553c6b6aa7ac320f00e5405548 (patch) | |
tree | 6cfbec33f6e385ceb5cbfa0168f4a9f27f0c8e57 /src/3rdparty/webkit/WebCore/inspector/front-end | |
parent | 5baebfc68dd67def412bcbaa7c61b43d05e6ee42 (diff) | |
download | Qt-57f1983c164bc8553c6b6aa7ac320f00e5405548.zip Qt-57f1983c164bc8553c6b6aa7ac320f00e5405548.tar.gz Qt-57f1983c164bc8553c6b6aa7ac320f00e5405548.tar.bz2 |
Updated WebKit from /home/jturcott/dev/webkit/ to qtwebkit-4.6-snapshot-22102009 ( 0639bb8e812c8923287cd5523248ca64fa5f7a50 )
Changes in WebKit/qt since the last update:
Jocelyn: fatal error from script, sha1 in src/3rdparty/webkit/VERSION is bad
Diffstat (limited to 'src/3rdparty/webkit/WebCore/inspector/front-end')
28 files changed, 1446 insertions, 665 deletions
diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js index 4f50ecc..aa0e08c 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ConsoleView.js @@ -27,6 +27,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +const ExpressionStopCharacters = " =:[({;,!+-*/&|^<>"; + WebInspector.ConsoleView = function(drawer) { WebInspector.View.call(this, document.getElementById("console-view")); @@ -44,7 +46,7 @@ WebInspector.ConsoleView = function(drawer) this.promptElement = document.getElementById("console-prompt"); this.promptElement.handleKeyEvent = this._promptKeyDown.bind(this); - this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), " .=:[({;"); + this.prompt = new WebInspector.TextPrompt(this.promptElement, this.completions.bind(this), ExpressionStopCharacters + "."); this.topGroup = new WebInspector.ConsoleGroup(null, 0); this.messagesElement.insertBefore(this.topGroup.element, this.promptElement); @@ -274,8 +276,7 @@ WebInspector.ConsoleView.prototype = { completions: function(wordRange, bestMatchOnly, completionsReadyCallback) { // Pass less stop characters to rangeOfWord so the range will be a more complete expression. - const expressionStopCharacters = " =:{;"; - var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOffset, expressionStopCharacters, this.promptElement, "backward"); + var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOffset, ExpressionStopCharacters, this.promptElement, "backward"); var expressionString = expressionRange.toString(); var lastIndex = expressionString.length - 1; @@ -292,16 +293,6 @@ WebInspector.ConsoleView.prototype = { var reportCompletions = this._reportCompletions.bind(this, bestMatchOnly, completionsReadyCallback, dotNotation, bracketNotation, prefix); // Collect comma separated object properties for the completion. - if (!expressionString) { - if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) { - // Evaluate into properties in scope of the selected call frame. - reportCompletions(WebInspector.panels.scripts.variablesInSelectedCallFrame()); - return; - } else { - expressionString = "this"; - } - } - var includeInspectorCommandLineAPI = (!dotNotation && !bracketNotation); if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) var callFrameId = WebInspector.panels.scripts.selectedCallFrameId(); @@ -343,7 +334,7 @@ WebInspector.ConsoleView.prototype = { if (bestMatchOnly) break; } - setTimeout(completionsReadyCallback, 0, results); + completionsReadyCallback(results); }, _clearButtonClicked: function() @@ -391,16 +382,16 @@ WebInspector.ConsoleView.prototype = { this.prompt.handleKeyEvent(event); }, - evalInInspectedWindow: function(expression, callback) + evalInInspectedWindow: function(expression, objectGroup, callback) { if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) { - WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, callback); + WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, objectGroup, callback); return; } - this.doEvalInWindow(expression, callback); + this.doEvalInWindow(expression, objectGroup, callback); }, - doEvalInWindow: function(expression, callback) + doEvalInWindow: function(expression, objectGroup, callback) { if (!expression) { // There is no expression, so the completion should happen against global properties. @@ -411,7 +402,7 @@ WebInspector.ConsoleView.prototype = { { callback(result.value, result.isException); }; - InjectedScriptAccess.evaluate(expression, evalCallback); + InjectedScriptAccess.evaluate(expression, objectGroup, evalCallback); }, _enterKeyPressed: function(event) @@ -439,7 +430,7 @@ WebInspector.ConsoleView.prototype = { self.prompt.text = ""; self.addMessage(new WebInspector.ConsoleCommandResult(result, exception, commandMessage)); } - this.evalInInspectedWindow(str, printResult); + this.evalInInspectedWindow(str, "console", printResult); }, _format: function(output, forceObjectFormat) @@ -514,21 +505,31 @@ WebInspector.ConsoleView.prototype = { _formatarray: function(arr, elem) { - var self = this; - function printResult(properties) - { - if (!properties) - return; - elem.appendChild(document.createTextNode("[")); - for (var i = 0; i < properties.length; ++i) { - var property = properties[i].value; - elem.appendChild(self._format(property)); - if (i < properties.length - 1) - elem.appendChild(document.createTextNode(", ")); - } - elem.appendChild(document.createTextNode("]")); + InjectedScriptAccess.getProperties(arr, false, this._printArray.bind(this, elem)); + }, + + _printArray: function(elem, properties) + { + if (!properties) + return; + var elements = []; + for (var i = 0; i < properties.length; ++i) { + var name = properties[i].name; + if (name == parseInt(name)) + elements[name] = this._format(properties[i].value); + } + + elem.appendChild(document.createTextNode("[")); + for (var i = 0; i < elements.length; ++i) { + var element = elements[i]; + if (element) + elem.appendChild(element); + else + elem.appendChild(document.createTextNode("undefined")) + if (i < elements.length - 1) + elem.appendChild(document.createTextNode(", ")); } - InjectedScriptAccess.getProperties(arr, false, printResult); + elem.appendChild(document.createTextNode("]")); }, _formatnode: function(object, elem) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/CookieItemsView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/CookieItemsView.js index f9604a4..9f9845c 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/CookieItemsView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/CookieItemsView.js @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.CookieItemsView = function() +WebInspector.CookieItemsView = function(cookieDomain) { WebInspector.View.call(this); @@ -40,6 +40,8 @@ WebInspector.CookieItemsView = function() this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item"); this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false); + + this._cookieDomain = cookieDomain; } WebInspector.CookieItemsView.prototype = { @@ -70,6 +72,7 @@ WebInspector.CookieItemsView.prototype = { if (dataGrid) { self._dataGrid = dataGrid; self.element.appendChild(dataGrid.element); + self._dataGrid.updateWidths(); if (isAdvanced) self.deleteButton.visible = true; } else { @@ -82,7 +85,7 @@ WebInspector.CookieItemsView.prototype = { } } - WebInspector.Cookies.getCookiesAsync(callback); + WebInspector.Cookies.getCookiesAsync(callback, this._cookieDomain); }, dataGridForCookies: function(cookies) @@ -246,6 +249,12 @@ WebInspector.CookieItemsView.prototype = { return dataGrid; }, + + resize: function() + { + if (this._dataGrid) + this._dataGrid.updateWidths(); + }, _deleteButtonClicked: function(event) { @@ -253,7 +262,7 @@ WebInspector.CookieItemsView.prototype = { return; var cookie = this._dataGrid.selectedNode.cookie; - InspectorController.deleteCookie(cookie.name); + InspectorController.deleteCookie(cookie.name, this._cookieDomain); this.update(); }, diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/DOMAgent.js b/src/3rdparty/webkit/WebCore/inspector/front-end/DOMAgent.js index a151c05..25ffafa 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/DOMAgent.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/DOMAgent.js @@ -307,13 +307,6 @@ WebInspector.DOMAgent = function() { this._window = new WebInspector.DOMWindow(this); this._idToDOMNode = null; this.document = null; - - // TODO: update ElementsPanel to not track embedded iframes - it is already being handled - // in the agent backend. - - // Whitespace is ignored in InspectorDOMAgent already -> no need to filter. - // TODO: Either remove all of its usages or push value into the agent backend. - Preferences.ignoreWhitespace = false; } WebInspector.DOMAgent.prototype = { @@ -417,10 +410,8 @@ WebInspector.DOMAgent.prototype = { node._childNodeCount = newValue; var outline = WebInspector.panels.elements.treeOutline; var treeElement = outline.findTreeElement(node); - if (treeElement) { + if (treeElement) treeElement.hasChildren = newValue; - treeElement.whitespaceIgnored = Preferences.ignoreWhitespace; - } }, _childNodeInserted: function(parentId, prevId, payload) @@ -446,7 +437,7 @@ WebInspector.DOMAgent.prototype = { WebInspector.Cookies = {} -WebInspector.Cookies.getCookiesAsync = function(callback) +WebInspector.Cookies.getCookiesAsync = function(callback, cookieDomain) { function mycallback(cookies, cookiesString) { if (cookiesString) @@ -455,7 +446,7 @@ WebInspector.Cookies.getCookiesAsync = function(callback) callback(cookies, true); } var callId = WebInspector.Callback.wrap(mycallback); - InspectorController.getCookies(callId); + InspectorController.getCookies(callId, cookieDomain); } WebInspector.Cookies.buildCookiesFromString = function(rawCookieString) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/Database.js b/src/3rdparty/webkit/WebCore/inspector/front-end/Database.js index dcab2ab..1a348fc 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/Database.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/Database.js @@ -26,18 +26,18 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.Database = function(database, domain, name, version) +WebInspector.Database = function(id, domain, name, version) { - this._database = database; - this.domain = domain; - this.name = name; - this.version = version; + this._id = id; + this._domain = domain; + this._name = name; + this._version = version; } WebInspector.Database.prototype = { - isDatabase: function(db) + get id() { - return this._database === db; + return this._id; }, get name() @@ -47,8 +47,6 @@ WebInspector.Database.prototype = { set name(x) { - if (this._name === x) - return; this._name = x; }, @@ -59,8 +57,6 @@ WebInspector.Database.prototype = { set version(x) { - if (this._version === x) - return; this._version = x; }, @@ -71,8 +67,6 @@ WebInspector.Database.prototype = { set domain(x) { - if (this._domain === x) - return; this._domain = x; }, @@ -83,31 +77,26 @@ WebInspector.Database.prototype = { getTableNames: function(callback) { - var names = InspectorController.databaseTableNames(this._database); - function sortingCallback() + function sortingCallback(names) { callback(names.sort()); } - setTimeout(sortingCallback, 0); + var callId = WebInspector.Callback.wrap(sortingCallback); + InspectorController.getDatabaseTableNames(callId, this._id); }, executeSql: function(query, onSuccess, onError) { - function successCallback(tx, result) + function callback(result) { + if (!(result instanceof Array)) { + onError(result); + return; + } onSuccess(result); } - - function errorCallback(tx, error) - { - onError(error); - } - - var self = this; - function queryTransaction(tx) - { - tx.executeSql(query, null, InspectorController.wrapCallback(successCallback.bind(self)), InspectorController.wrapCallback(errorCallback.bind(self))); - } - this._database.transaction(InspectorController.wrapCallback(queryTransaction.bind(this)), InspectorController.wrapCallback(errorCallback.bind(this))); + InjectedScriptAccess.executeSql(this._id, query, callback); } } + +WebInspector.didGetDatabaseTableNames = WebInspector.Callback.processCallback; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js index 1b61a7b..5d0e6d7 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js @@ -60,7 +60,7 @@ WebInspector.ElementsPanel = function() if (InspectorController.searchingForNode()) { InspectorController.toggleNodeSearch(); - this.panel.nodeSearchButton.removeStyleClass("toggled-on"); + this.panel.nodeSearchButton.toggled = false; } if (this._focusedDOMNode) InjectedScriptAccess.addInspectedNode(this._focusedDOMNode.id, function() {}); @@ -479,7 +479,7 @@ WebInspector.ElementsPanel.prototype = { updatedParentTreeElements.push(parentNodeItem); } - if (!updateBreadcrumbs && (this.focusedDOMNode === parent || isAncestor(this.focusedDOMNode, parent))) + if (!updateBreadcrumbs && (this.focusedDOMNode === parent || isAncestorNode(this.focusedDOMNode, parent))) updateBreadcrumbs = true; } diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js index d8c4d89..c4bd372 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -115,12 +115,12 @@ WebInspector.ElementsTreeOutline.prototype = { this.appendChild(treeElement); } else { // FIXME: this could use findTreeElement to reuse a tree element if it already exists - var node = (Preferences.ignoreWhitespace ? firstChildSkippingWhitespace.call(this.rootDOMNode) : this.rootDOMNode.firstChild); + var node = this.rootDOMNode.firstChild; while (node) { treeElement = new WebInspector.ElementsTreeElement(node); treeElement.selectable = this.selectEnabled; this.appendChild(treeElement); - node = Preferences.ignoreWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling; + node = node.nextSibling; } } @@ -184,6 +184,34 @@ WebInspector.ElementsTreeOutline.prototype = { return element; }, + + handleKeyEvent: function(event) + { + var selectedElement = this.selectedTreeElement; + if (!selectedElement) + return; + + // Delete or backspace pressed, delete the node. + if (event.keyCode === 8 || event.keyCode === 46) { + selectedElement.remove(); + return; + } + + // On Enter or Return start editing the first attribute + // or create a new attribute on the selected element. + if (event.keyIdentifier === "Enter") { + if (this._editing) + return; + + selectedElement._startEditing(); + + // prevent a newline from being immediately inserted + event.preventDefault(); + return; + } + + TreeOutline.prototype.handleKeyEvent.call(this, event); + }, _onmousedown: function(event) { @@ -197,12 +225,15 @@ WebInspector.ElementsTreeOutline.prototype = { _onmousemove: function(event) { + var element = this._treeElementFromEvent(event); + if (element && this._previousHoveredElement === element) + return; + if (this._previousHoveredElement) { this._previousHoveredElement.hovered = false; delete this._previousHoveredElement; } - var element = this._treeElementFromEvent(event); if (element && !element.elementCloseTag) { element.hovered = true; this._previousHoveredElement = element; @@ -230,14 +261,10 @@ WebInspector.ElementsTreeOutline.prototype.__proto__ = TreeOutline.prototype; WebInspector.ElementsTreeElement = function(node) { - var hasChildren = Preferences.ignoreWhitespace ? (firstChildSkippingWhitespace.call(node) ? true : false) : node.hasChildNodes(); - var titleInfo = nodeTitleInfo.call(node, hasChildren, WebInspector.linkifyURL); - - if (titleInfo.hasChildren) - this.whitespaceIgnored = Preferences.ignoreWhitespace; + var hasChildrenOverride = node.hasChildNodes() && !this._showInlineText(node); // The title will be updated in onattach. - TreeElement.call(this, "", node, titleInfo.hasChildren); + TreeElement.call(this, "", node, hasChildrenOverride); if (this.representedObject.nodeType == Node.ELEMENT_NODE) this._canAddAttributes = true; @@ -280,36 +307,39 @@ WebInspector.ElementsTreeElement.prototype = { if (x) { this.updateSelection(); this.listItemElement.addStyleClass("hovered"); - } else + if (this._canAddAttributes) + this._pendingToggleNewAttribute = setTimeout(this.toggleNewAttributeButton.bind(this, true), 500); + } else { this.listItemElement.removeStyleClass("hovered"); - if (this._canAddAttributes) - this.toggleNewAttributeButton(); + if (this._pendingToggleNewAttribute) { + clearTimeout(this._pendingToggleNewAttribute); + delete this._pendingToggleNewAttribute; + } + this.toggleNewAttributeButton(false); + } } }, - toggleNewAttributeButton: function() + toggleNewAttributeButton: function(visible) { - function removeWhenEditing(event) + function removeAddAttributeSpan() { if (this._addAttributeElement && this._addAttributeElement.parentNode) this._addAttributeElement.parentNode.removeChild(this._addAttributeElement); delete this._addAttributeElement; } - if (!this._addAttributeElement && this._hovered && !this._editing) { + if (!this._addAttributeElement && visible && !this._editing) { var span = document.createElement("span"); - span.className = "add-attribute"; - span.textContent = "\u2026"; - span.addEventListener("dblclick", removeWhenEditing.bind(this), false); + span.className = "add-attribute webkit-html-attribute-name"; + span.textContent = " ?=\"\""; + span.addEventListener("dblclick", removeAddAttributeSpan.bind(this), false); this._addAttributeElement = span; var tag = this.listItemElement.getElementsByClassName("webkit-html-tag")[0]; this._insertInLastAttributePosition(tag, span); - } else if (!this._hovered && this._addAttributeElement) { - if (this._addAttributeElement.parentNode) - this._addAttributeElement.parentNode.removeChild(this._addAttributeElement); - delete this._addAttributeElement; - } + } else if (!visible && this._addAttributeElement) + removeAddAttributeSpan.call(this); }, updateSelection: function() @@ -362,11 +392,9 @@ WebInspector.ElementsTreeElement.prototype = { onpopulate: function() { - if (this.children.length || this.whitespaceIgnored !== Preferences.ignoreWhitespace) + if (this.children.length || this._showInlineText(this.representedObject)) return; - this.whitespaceIgnored = Preferences.ignoreWhitespace; - this.updateChildren(); }, @@ -390,7 +418,7 @@ WebInspector.ElementsTreeElement.prototype = { function updateChildrenOfNode(node) { var treeOutline = treeElement.treeOutline; - var child = (Preferences.ignoreWhitespace ? firstChildSkippingWhitespace.call(node) : node.firstChild); + var child = node.firstChild; while (child) { var currentTreeElement = treeElement.children[treeChildIndex]; if (!currentTreeElement || currentTreeElement.representedObject !== child) { @@ -418,7 +446,7 @@ WebInspector.ElementsTreeElement.prototype = { } } - child = Preferences.ignoreWhitespace ? nextSiblingSkippingWhitespace.call(child) : child.nextSibling; + child = child.nextSibling; ++treeChildIndex; } } @@ -491,7 +519,7 @@ WebInspector.ElementsTreeElement.prototype = { if (this._editing) return; - if (this._startEditing(event, treeElement)) + if (this._startEditingFromEvent(event, treeElement)) return; if (this.treeOutline.panel) { @@ -516,7 +544,7 @@ WebInspector.ElementsTreeElement.prototype = { } }, - _startEditing: function(event, treeElement) + _startEditingFromEvent: function(event, treeElement) { if (this.treeOutline.focusedDOMNode != this.representedObject) return; @@ -539,6 +567,30 @@ WebInspector.ElementsTreeElement.prototype = { return false; }, + _startEditing: function() + { + if (this.treeOutline.focusedDOMNode !== this.representedObject) + return; + + var listItem = this._listItemNode; + + if (this._canAddAttributes) { + this.toggleNewAttributeButton(false); + var attribute = listItem.getElementsByClassName("webkit-html-attribute")[0]; + if (attribute) + return this._startEditingAttribute(attribute, attribute.getElementsByClassName("webkit-html-attribute-name")[0]); + + return this._addNewAttribute(listItem); + } + + if (this.representedObject.nodeType === Node.TEXT_NODE) { + var textNode = listItem.getElementsByClassName("webkit-html-text-node")[0]; + if (textNode) + return this._startEditingTextNode(textNode); + return; + } + }, + _addNewAttribute: function(listItemElement) { var attr = document.createElement("span"); @@ -646,7 +698,7 @@ WebInspector.ElementsTreeElement.prototype = { } } - if (!found && moveDirection === "backward") + if (!found && moveDirection === "backward" && attributes.length > 0) moveToAttribute = attributes[attributes.length - 1].name; else if (!found && moveDirection === "forward" && !/^\s*$/.test(newText)) newAttribute = true; @@ -720,12 +772,138 @@ WebInspector.ElementsTreeElement.prototype = { _updateTitle: function() { - var title = nodeTitleInfo.call(this.representedObject, this.hasChildren, WebInspector.linkifyURL).title; + var title = this._nodeTitleInfo(this.representedObject, this.hasChildren, WebInspector.linkifyURL).title; this.title = "<span class=\"highlight\">" + title + "</span>"; delete this.selectionElement; this.updateSelection(); this._preventFollowingLinksOnDoubleClick(); }, + + _nodeTitleInfo: function(node, hasChildren, linkify) + { + var info = {title: "", hasChildren: hasChildren}; + + switch (node.nodeType) { + case Node.DOCUMENT_NODE: + info.title = "Document"; + break; + + case Node.ELEMENT_NODE: + info.title = "<span class=\"webkit-html-tag\"><" + node.nodeName.toLowerCase().escapeHTML(); + + if (node.hasAttributes()) { + for (var i = 0; i < node.attributes.length; ++i) { + var attr = node.attributes[i]; + info.title += " <span class=\"webkit-html-attribute\"><span class=\"webkit-html-attribute-name\">" + attr.name.escapeHTML() + "</span>=​\""; + + var value = attr.value; + if (linkify && (attr.name === "src" || attr.name === "href")) { + var value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B"); + info.title += linkify(attr.value, value, "webkit-html-attribute-value", node.nodeName.toLowerCase() == "a"); + } else { + var value = value.escapeHTML(); + value = value.replace(/([\/;:\)\]\}])/g, "$1​"); + info.title += "<span class=\"webkit-html-attribute-value\">" + value + "</span>"; + } + info.title += "\"</span>"; + } + } + info.title += "></span>​"; + + // If this element only has a single child that is a text node, + // just show that text and the closing tag inline rather than + // create a subtree for them + + var textChild = onlyTextChild.call(node); + var showInlineText = textChild && textChild.textContent.length < Preferences.maxInlineTextChildLength; + + if (showInlineText) { + info.title += "<span class=\"webkit-html-text-node\">" + textChild.nodeValue.escapeHTML() + "</span>​<span class=\"webkit-html-tag\"></" + node.nodeName.toLowerCase().escapeHTML() + "></span>"; + info.hasChildren = false; + } + break; + + case Node.TEXT_NODE: + if (isNodeWhitespace.call(node)) + info.title = "(whitespace)"; + else { + if (node.parentNode && node.parentNode.nodeName.toLowerCase() == "script") { + var newNode = document.createElement("span"); + newNode.textContent = node.textContent; + + var javascriptSyntaxHighlighter = new WebInspector.JavaScriptSourceSyntaxHighlighter(null, null); + javascriptSyntaxHighlighter.syntaxHighlightLine(newNode, null); + + info.title = "<span class=\"webkit-html-text-node webkit-html-js-node\">" + newNode.innerHTML.replace(/^[\n\r]*/, "").replace(/\s*$/, "") + "</span>"; + } else if (node.parentNode && node.parentNode.nodeName.toLowerCase() == "style") { + var newNode = document.createElement("span"); + newNode.textContent = node.textContent; + + var cssSyntaxHighlighter = new WebInspector.CSSSourceSyntaxHighligher(null, null); + cssSyntaxHighlighter.syntaxHighlightLine(newNode, null); + + info.title = "<span class=\"webkit-html-text-node webkit-html-css-node\">" + newNode.innerHTML.replace(/^[\n\r]*/, "").replace(/\s*$/, "") + "</span>"; + } else { + info.title = "\"<span class=\"webkit-html-text-node\">" + node.nodeValue.escapeHTML() + "</span>\""; + } + } + break; + + case Node.COMMENT_NODE: + info.title = "<span class=\"webkit-html-comment\"><!--" + node.nodeValue.escapeHTML() + "--></span>"; + break; + + case Node.DOCUMENT_TYPE_NODE: + info.title = "<span class=\"webkit-html-doctype\"><!DOCTYPE " + node.nodeName; + if (node.publicId) { + info.title += " PUBLIC \"" + node.publicId + "\""; + if (node.systemId) + info.title += " \"" + node.systemId + "\""; + } else if (node.systemId) + info.title += " SYSTEM \"" + node.systemId + "\""; + if (node.internalSubset) + info.title += " [" + node.internalSubset + "]"; + info.title += "></span>"; + break; + default: + info.title = node.nodeName.toLowerCase().collapseWhitespace().escapeHTML(); + } + + return info; + }, + + _showInlineText: function(node) + { + if (node.nodeType === Node.ELEMENT_NODE) { + var textChild = onlyTextChild.call(node); + if (textChild && textChild.textContent.length < Preferences.maxInlineTextChildLength) + return true; + } + return false; + }, + + remove: function() + { + var parentElement = this.parent; + if (!parentElement) + return; + + var self = this; + function removeNodeCallback(removedNodeId) + { + // -1 is an error code, which means removing the node from the DOM failed, + // so we shouldn't remove it from the tree. + if (removedNodeId === -1) + return; + + parentElement.removeChild(self); + } + + var callId = WebInspector.Callback.wrap(removeNodeCallback); + InspectorController.removeNode(callId, this.representedObject.id); + } } WebInspector.ElementsTreeElement.prototype.__proto__ = TreeElement.prototype; + +WebInspector.didRemoveNode = WebInspector.Callback.processCallback; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js index 87293b8..3ce96d0 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScript.js @@ -41,9 +41,12 @@ InjectedScript.reset = function() InjectedScript.reset(); -InjectedScript.dispatch = function(methodName, args) +InjectedScript.dispatch = function(methodName, args, callId) { - var result = InjectedScript[methodName].apply(InjectedScript, JSON.parse(args)); + var argsArray = JSON.parse(args); + if (callId) + argsArray.splice(0, 0, callId); // Methods that run asynchronously have a call back id parameter. + var result = InjectedScript[methodName].apply(InjectedScript, argsArray); if (typeof result === "undefined") { InjectedScript._window().console.error("Web Inspector error: InjectedScript.%s returns undefined", methodName); result = null; @@ -514,12 +517,28 @@ InjectedScript.getCompletions = function(expression, includeInspectorCommandLine var callFrame = InjectedScript._callFrameForId(callFrameId); if (!callFrame) return props; - expressionResult = InjectedScript._evaluateOn(callFrame.evaluate, callFrame, expression); + if (expression) + expressionResult = InjectedScript._evaluateOn(callFrame.evaluate, callFrame, expression); + else { + // Evaluate into properties in scope of the selected call frame. + var scopeChain = callFrame.scopeChain; + for (var i = 0; i < scopeChain.length; ++i) { + var scopeObject = scopeChain[i]; + try { + for (var propertyName in scopeObject) + props[propertyName] = true; + } catch (e) { + } + } + } } else { + if (!expression) + expression = "this"; expressionResult = InjectedScript._evaluateOn(InjectedScript._window().eval, InjectedScript._window(), expression); } - for (var prop in expressionResult) - props[prop] = true; + if (expressionResult) + for (var prop in expressionResult) + props[prop] = true; if (includeInspectorCommandLineAPI) for (var prop in InjectedScript._window()._inspectorCommandLineAPI) if (prop.charAt(0) !== '_') @@ -529,16 +548,16 @@ InjectedScript.getCompletions = function(expression, includeInspectorCommandLine return props; } -InjectedScript.evaluate = function(expression) +InjectedScript.evaluate = function(expression, objectGroup) { - return InjectedScript._evaluateAndWrap(InjectedScript._window().eval, InjectedScript._window(), expression); + return InjectedScript._evaluateAndWrap(InjectedScript._window().eval, InjectedScript._window(), expression, objectGroup); } -InjectedScript._evaluateAndWrap = function(evalFunction, object, expression) +InjectedScript._evaluateAndWrap = function(evalFunction, object, expression, objectGroup) { var result = {}; try { - result.value = InspectorController.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression)); + result.value = InspectorController.wrapObject(InjectedScript._evaluateOn(evalFunction, object, expression), objectGroup); // Handle error that might have happened while describing result. if (result.value.errorText) { result.value = result.value.errorText; @@ -553,7 +572,7 @@ InjectedScript._evaluateAndWrap = function(evalFunction, object, expression) InjectedScript._evaluateOn = function(evalFunction, object, expression) { - InjectedScript._ensureCommandLineAPIInstalled(); + InjectedScript._ensureCommandLineAPIInstalled(evalFunction, object); // Surround the expression in with statements to inject our command line API so that // the window object properties still take more precedent than our API functions. expression = "with (window._inspectorCommandLineAPI) { with (window) { " + expression + " } }"; @@ -572,7 +591,7 @@ InjectedScript.addInspectedNode = function(nodeId) if (!node) return false; - InjectedScript._ensureCommandLineAPIInstalled(); + InjectedScript._ensureCommandLineAPIInstalled(InjectedScript._window().eval, InjectedScript._window()); var inspectedNodes = InjectedScript._window()._inspectorCommandLineAPI._inspectedNodes; inspectedNodes.unshift(node); if (inspectedNodes.length >= 5) @@ -838,12 +857,12 @@ InjectedScript.getCallFrames = function() return result; } -InjectedScript.evaluateInCallFrame = function(callFrameId, code) +InjectedScript.evaluateInCallFrame = function(callFrameId, code, objectGroup) { var callFrame = InjectedScript._callFrameForId(callFrameId); if (!callFrame) return false; - return InjectedScript._evaluateAndWrap(callFrame.evaluate, callFrame, code); + return InjectedScript._evaluateAndWrap(callFrame.evaluate, callFrame, code, objectGroup); } InjectedScript._callFrameForId = function(id) @@ -880,13 +899,11 @@ InjectedScript._inspectObject = function(o) } } -InjectedScript._ensureCommandLineAPIInstalled = function(inspectedWindow) +InjectedScript._ensureCommandLineAPIInstalled = function(evalFunction, evalObject) { - var inspectedWindow = InjectedScript._window(); - if (inspectedWindow._inspectorCommandLineAPI) + if (evalFunction.call(evalObject, "window._inspectorCommandLineAPI")) return; - - inspectedWindow.eval("window._inspectorCommandLineAPI = { \ + var inspectorCommandLineAPI = evalFunction.call(evalObject, "window._inspectorCommandLineAPI = { \ $: function() { return document.getElementById.apply(document, arguments) }, \ $$: function() { return document.querySelectorAll.apply(document, arguments) }, \ $x: function(xpath, context) { \ @@ -913,8 +930,8 @@ InjectedScript._ensureCommandLineAPIInstalled = function(inspectedWindow) get $4() { return _inspectorCommandLineAPI._inspectedNodes[4] } \ };"); - inspectedWindow._inspectorCommandLineAPI.clear = InspectorController.wrapCallback(InjectedScript._clearConsoleMessages); - inspectedWindow._inspectorCommandLineAPI.inspect = InspectorController.wrapCallback(InjectedScript._inspectObject); + inspectorCommandLineAPI.clear = InspectorController.wrapCallback(InjectedScript._clearConsoleMessages); + inspectorCommandLineAPI.inspect = InspectorController.wrapCallback(InjectedScript._inspectObject); } InjectedScript._resolveObject = function(objectProxy) @@ -1031,18 +1048,51 @@ InjectedScript.CallFrameProxy.prototype = { scopeObjectProxy.isDocument = true; else if (!foundLocalScope) scopeObjectProxy.isWithBlock = true; - scopeObjectProxy.properties = []; - try { - for (var propertyName in scopeObject) - scopeObjectProxy.properties.push(propertyName); - } catch (e) { - } scopeChainProxy.push(scopeObjectProxy); } return scopeChainProxy; } } +InjectedScript.executeSql = function(callId, databaseId, query) +{ + function successCallback(tx, result) + { + var rows = result.rows; + var result = []; + var length = rows.length; + for (var i = 0; i < length; ++i) { + var data = {}; + result.push(data); + var row = rows.item(i); + for (var columnIdentifier in row) { + // FIXME: (Bug 19439) We should specially format SQL NULL here + // (which is represented by JavaScript null here, and turned + // into the string "null" by the String() function). + var text = row[columnIdentifier]; + data[columnIdentifier] = String(text); + } + } + InspectorController.reportDidDispatchOnInjectedScript(callId, JSON.stringify(result), false); + } + + function errorCallback(tx, error) + { + InspectorController.reportDidDispatchOnInjectedScript(callId, JSON.stringify(error), false); + } + + function queryTransaction(tx) + { + tx.executeSql(query, null, InspectorController.wrapCallback(successCallback), InspectorController.wrapCallback(errorCallback)); + } + + var database = InspectorController.databaseForId(databaseId); + if (!database) + errorCallback(null, { code : 2 }); // Return as unexpected version. + database.transaction(InspectorController.wrapCallback(queryTransaction), InspectorController.wrapCallback(errorCallback)); + return true; +} + Object.type = function(obj) { if (obj === null) @@ -1068,6 +1118,8 @@ Object.type = function(obj) return "date"; if (obj instanceof win.RegExp) return "regexp"; + if (obj instanceof win.NodeList) + return "array"; if (obj instanceof win.Error) return "error"; return type; @@ -1090,9 +1142,8 @@ Object.describe = function(obj, abbreviated) switch (type1) { case "object": case "node": - return type2; case "array": - return "[" + obj.toString() + "]"; + return type2; case "string": if (!abbreviated) return obj; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js index 67312f7..c6d4b65 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/InjectedScriptAccess.js @@ -31,7 +31,7 @@ var InjectedScriptAccess = {}; -InjectedScriptAccess._installHandler = function(methodName) +InjectedScriptAccess._installHandler = function(methodName, async) { InjectedScriptAccess[methodName] = function() { @@ -47,35 +47,37 @@ InjectedScriptAccess._installHandler = function(methodName) WebInspector.console.addMessage(new WebInspector.ConsoleTextMessage("Error dispatching: " + methodName)); } var callId = WebInspector.Callback.wrap(myCallback); - InspectorController.dispatchOnInjectedScript(callId, methodName, argsString); + InspectorController.dispatchOnInjectedScript(callId, methodName, argsString, !!async); }; } // InjectedScriptAccess message forwarding puts some constraints on the way methods are imlpemented and called: // - Make sure corresponding methods in InjectedScript return non-null and non-undefined values, // - Make sure last parameter of all the InjectedSriptAccess.* calls is a callback function. -InjectedScriptAccess._installHandler("getStyles"); +// We keep these sorted. +InjectedScriptAccess._installHandler("addInspectedNode"); +InjectedScriptAccess._installHandler("addStyleSelector"); +InjectedScriptAccess._installHandler("applyStyleRuleText"); +InjectedScriptAccess._installHandler("applyStyleText"); +InjectedScriptAccess._installHandler("evaluate"); +InjectedScriptAccess._installHandler("evaluateInCallFrame"); +InjectedScriptAccess._installHandler("getCompletions"); InjectedScriptAccess._installHandler("getComputedStyle"); InjectedScriptAccess._installHandler("getInlineStyle"); -InjectedScriptAccess._installHandler("applyStyleText"); -InjectedScriptAccess._installHandler("setStyleText"); -InjectedScriptAccess._installHandler("toggleStyleEnabled"); -InjectedScriptAccess._installHandler("applyStyleRuleText"); -InjectedScriptAccess._installHandler("addStyleSelector"); -InjectedScriptAccess._installHandler("setStyleProperty"); -InjectedScriptAccess._installHandler("getPrototypes"); InjectedScriptAccess._installHandler("getProperties"); -InjectedScriptAccess._installHandler("setPropertyValue"); -InjectedScriptAccess._installHandler("getCompletions"); -InjectedScriptAccess._installHandler("evaluate"); -InjectedScriptAccess._installHandler("addInspectedNode"); -InjectedScriptAccess._installHandler("pushNodeToFrontend"); -InjectedScriptAccess._installHandler("evaluate"); -InjectedScriptAccess._installHandler("addInspectedNode"); -InjectedScriptAccess._installHandler("pushNodeToFrontend"); +InjectedScriptAccess._installHandler("getPrototypes"); +InjectedScriptAccess._installHandler("getStyles"); +InjectedScriptAccess._installHandler("openInInspectedWindow"); InjectedScriptAccess._installHandler("performSearch"); +InjectedScriptAccess._installHandler("pushNodeToFrontend"); InjectedScriptAccess._installHandler("searchCanceled"); -InjectedScriptAccess._installHandler("openInInspectedWindow"); -InjectedScriptAccess._installHandler("evaluateInCallFrame"); +InjectedScriptAccess._installHandler("setPropertyValue"); +InjectedScriptAccess._installHandler("setStyleProperty"); +InjectedScriptAccess._installHandler("setStyleText"); +InjectedScriptAccess._installHandler("toggleStyleEnabled"); + +// Some methods can't run synchronously even on the injected script side (such as DB transactions). +// Mark them as asynchronous here. +InjectedScriptAccess._installHandler("executeSql", true); WebInspector.didDispatchOnInjectedScript = WebInspector.Callback.processCallback; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/Object.js b/src/3rdparty/webkit/WebCore/inspector/front-end/Object.js index 80202b0..74fb56e 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/Object.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/Object.js @@ -67,10 +67,10 @@ WebInspector.Object.prototype = { } var event = {target: this, type: eventType, defaultPrevented: false}; - event.stopPropagation = stopPropagation.bind(event); - event.preventDefault = preventDefault.bind(event); + event.stopPropagation = stopPropagation; + event.preventDefault = preventDefault; - var listeners = this._listeners[eventType]; + var listeners = this._listeners[eventType].slice(0); for (var i = 0; i < listeners.length; ++i) { listeners[i].listener.call(listeners[i].thisObject, event); if (stoppedPropagation) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileView.js index 2b8c6ce..ee96345 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfileView.js @@ -23,7 +23,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.ProfileView = function(profile) +// FIXME: Rename the file. + +WebInspector.CPUProfileView = function(profile) { WebInspector.View.call(this); @@ -78,15 +80,25 @@ WebInspector.ProfileView = function(profile) this.profile = profile; - this.profileDataGridTree = this.bottomUpProfileDataGridTree; - this.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator("selfTime", false)); - - this.refresh(); + var self = this; + function profileCallback(profile) + { + self.profile.representedObject = profile; + self._assignParentsInProfile(); + + self.profileDataGridTree = self.bottomUpProfileDataGridTree; + self.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator("selfTime", false)); + + self.refresh(); + + self._updatePercentButton(); + } - this._updatePercentButton(); + var callId = WebInspector.Callback.wrap(profileCallback); + InspectorController.getProfile(callId, this.profile.uid); } -WebInspector.ProfileView.prototype = { +WebInspector.CPUProfileView.prototype = { get statusBarItems() { return [this.viewSelectElement, this.percentButton.element, this.focusButton.element, this.excludeButton.element, this.resetButton.element]; @@ -158,7 +170,7 @@ WebInspector.ProfileView.prototype = { WebInspector.View.prototype.hide.call(this); this._currentSearchResultIndex = -1; }, - + resize: function() { if (this.dataGrid) @@ -493,7 +505,7 @@ WebInspector.ProfileView.prototype = { _sortData: function(event) { - this._sortProfile(this.profile); + this._sortProfile(this.profile.representedObject); }, _sortProfile: function() @@ -533,7 +545,100 @@ WebInspector.ProfileView.prototype = { event.preventDefault(); event.stopPropagation(); + }, + + _assignParentsInProfile: function() + { + var head = this.profile.head; + head.parent = null; + head.head = null; + var nodesToTraverse = [ { parent: head, children: head.children } ]; + while (nodesToTraverse.length > 0) { + var pair = nodesToTraverse.shift(); + var parent = pair.parent; + var children = pair.children; + var length = children.length; + for (var i = 0; i < length; ++i) { + children[i].head = head; + children[i].parent = parent; + if (children[i].children.length > 0) + nodesToTraverse.push({ parent: children[i], children: children[i].children }); + } + } + } +} + +WebInspector.CPUProfileView.prototype.__proto__ = WebInspector.View.prototype; + +WebInspector.CPUProfileType = function() +{ + WebInspector.ProfileType.call(this, WebInspector.CPUProfileType.TypeId, WebInspector.UIString("CPU PROFILES")); + this._recording = false; +} + +WebInspector.CPUProfileType.TypeId = "CPU"; + +WebInspector.CPUProfileType.prototype = { + get buttonTooltip() + { + return this._recording ? WebInspector.UIString("Stop profiling.") : WebInspector.UIString("Start profiling."); + }, + + get buttonStyle() + { + return this._recording ? "record-profile-status-bar-item status-bar-item toggled-on" : "record-profile-status-bar-item status-bar-item"; + }, + + buttonClicked: function() + { + this._recording = !this._recording; + + if (this._recording) + InspectorController.startProfiling(); + else + InspectorController.stopProfiling(); + }, + + setRecordingProfile: function(isProfiling) + { + this._recording = isProfiling; } } -WebInspector.ProfileView.prototype.__proto__ = WebInspector.View.prototype; +WebInspector.CPUProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; + +WebInspector.CPUProfile = function(profile) +{ + this.representedObject = profile; + this.typeId = WebInspector.CPUProfileType.TypeId; +} + +WebInspector.CPUProfile.prototype = { + get title() + { + return this.representedObject.title; + }, + + get uid() + { + return this.representedObject.uid; + }, + + get head() + { + return this.representedObject.head; + }, + + createView: function() + { + return new WebInspector.CPUProfileView(this); + }, + + // FIXME: Extract this into a superclass so that createView can be simply overridden by subclasses. + viewForProfile: function() + { + if (!this._profileView) + this._profileView = this.createView(); + return this._profileView; + } +} diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js index 3bd4464..55e286e 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ProfilesPanel.js @@ -25,11 +25,52 @@ const UserInitiatedProfileName = "org.webkit.profiles.user-initiated"; +WebInspector.ProfileType = function(id, name) +{ + this._id = id; + this._name = name; +} + +WebInspector.ProfileType.URLRegExp = /webkit-profile:\/\/(.+)\/(.+)#([0-9]+)/; + +WebInspector.ProfileType.prototype = { + get buttonTooltip() + { + return ""; + }, + + get buttonStyle() + { + return undefined; + }, + + get buttonCaption() + { + return this.name; + }, + + get id() + { + return this._id; + }, + + get name() + { + return this._name; + }, + + buttonClicked: function() + { + } +} + WebInspector.ProfilesPanel = function() { WebInspector.Panel.call(this); this.element.addStyleClass("profiles"); + this._profileTypesByIdMap = {}; + this._profileTypeButtonsByIdMap = {}; var panelEnablerHeading = WebInspector.UIString("You need to enable profiling before you can use the Profiles panel."); var panelEnablerDisclaimer = WebInspector.UIString("Enabling profiling will make scripts run slower."); @@ -52,19 +93,8 @@ WebInspector.ProfilesPanel = function() this.sidebarTreeElement = document.createElement("ol"); this.sidebarTreeElement.className = "sidebar-tree"; this.sidebarElement.appendChild(this.sidebarTreeElement); - this.sidebarTree = new TreeOutline(this.sidebarTreeElement); - this.profilesListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("CPU PROFILES"), null, true); - this.sidebarTree.appendChild(this.profilesListTreeElement); - this.profilesListTreeElement.expand(); - - this.snapshotsListTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("HEAP SNAPSHOTS"), null, true); - if (Preferences.heapProfilerPresent) { - this.sidebarTree.appendChild(this.snapshotsListTreeElement); - this.snapshotsListTreeElement.expand(); - } - this.profileViews = document.createElement("div"); this.profileViews.id = "profile-views"; this.element.appendChild(this.profileViews); @@ -72,18 +102,10 @@ WebInspector.ProfilesPanel = function() this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item"); this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind(this), false); - this.recordButton = new WebInspector.StatusBarButton(WebInspector.UIString("Start profiling."), "record-profile-status-bar-item"); - this.recordButton.addEventListener("click", this._recordClicked.bind(this), false); - - this.recording = false; - - this.snapshotButton = new WebInspector.StatusBarButton(WebInspector.UIString("Take heap snapshot."), "heap-snapshot-status-bar-item"); - this.snapshotButton.visible = Preferences.heapProfilerPresent; - this.snapshotButton.addEventListener("click", this._snapshotClicked.bind(this), false); - this.profileViewStatusBarItemsContainer = document.createElement("div"); this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items"; + this._profiles = []; this.reset(); } @@ -97,7 +119,25 @@ WebInspector.ProfilesPanel.prototype = { get statusBarItems() { - return [this.enableToggleButton.element, this.recordButton.element, this.snapshotButton.element, this.profileViewStatusBarItemsContainer]; + function clickHandler(profileType, buttonElement) + { + profileType.buttonClicked.call(profileType); + this.updateProfileTypeButtons(); + } + + var items = [this.enableToggleButton.element]; + // FIXME: Generate a single "combo-button". + for (var typeId in this._profileTypesByIdMap) { + var profileType = this.getProfileType(typeId); + if (profileType.buttonStyle) { + var button = new WebInspector.StatusBarButton(profileType.buttonTooltip, profileType.buttonStyle, profileType.buttonCaption); + this._profileTypeButtonsByIdMap[typeId] = button.element; + button.element.addEventListener("click", clickHandler.bind(this, profileType, button.element), false); + items.push(button.element); + } + } + items.push(this.profileViewStatusBarItemsContainer); + return items; }, show: function() @@ -129,13 +169,8 @@ WebInspector.ProfilesPanel.prototype = { reset: function() { - if (this._profiles) { - var profiledLength = this._profiles.length; - for (var i = 0; i < profiledLength; ++i) { - var profile = this._profiles[i]; - delete profile._profileView; - } - } + for (var i = 0; i < this._profiles.length; ++i) + delete this._profiles[i]._profileView; delete this.currentQuery; this.searchCanceled(); @@ -147,8 +182,9 @@ WebInspector.ProfilesPanel.prototype = { this.sidebarTreeElement.removeStyleClass("some-expandable"); - this.profilesListTreeElement.removeChildren(); - this.snapshotsListTreeElement.removeChildren(); + for (var typeId in this._profileTypesByIdMap) + this.getProfileType(typeId).treeElement.removeChildren(); + this.profileViews.removeChildren(); this.profileViewStatusBarItemsContainer.removeChildren(); @@ -161,20 +197,34 @@ WebInspector.ProfilesPanel.prototype = { this.sidebarTree.handleKeyEvent(event); }, - addProfile: function(profile) + registerProfileType: function(profileType) { - this._profiles.push(profile); - this._profilesIdMap[profile.uid] = profile; + this._profileTypesByIdMap[profileType.id] = profileType; + profileType.treeElement = new WebInspector.SidebarSectionTreeElement(profileType.name, null, true); + this.sidebarTree.appendChild(profileType.treeElement); + profileType.treeElement.expand(); + }, + + _makeKey: function(text, profileTypeId) + { + return escape(text) + '/' + escape(profileTypeId); + }, - var sidebarParent = this.profilesListTreeElement; + addProfileHeader: function(typeId, profile) + { + var sidebarParent = this.getProfileType(typeId).treeElement; var small = false; var alternateTitle; + this._profiles.push(profile); + this._profilesIdMap[this._makeKey(profile.uid, typeId)] = profile; + if (profile.title.indexOf(UserInitiatedProfileName) !== 0) { - if (!(profile.title in this._profileGroups)) - this._profileGroups[profile.title] = []; + var profileTitleKey = this._makeKey(profile.title, typeId); + if (!(profileTitleKey in this._profileGroups)) + this._profileGroups[profileTitleKey] = []; - var group = this._profileGroups[profile.title]; + var group = this._profileGroups[profileTitleKey]; group.push(profile); if (group.length === 2) { @@ -182,12 +232,12 @@ WebInspector.ProfilesPanel.prototype = { group._profilesTreeElement = new WebInspector.ProfileGroupSidebarTreeElement(profile.title); // Insert at the same index for the first profile of the group. - var index = this.sidebarTree.children.indexOf(group[0]._profilesTreeElement); - this.sidebarTree.insertChild(group._profilesTreeElement, index); + var index = sidebarParent.children.indexOf(group[0]._profilesTreeElement); + sidebarParent.insertChild(group._profilesTreeElement, index); // Move the first profile to the group. var selected = group[0]._profilesTreeElement.selected; - this.sidebarTree.removeChild(group[0]._profilesTreeElement); + sidebarParent.removeChild(group[0]._profilesTreeElement); group._profilesTreeElement.appendChild(group[0]._profilesTreeElement); if (selected) { group[0]._profilesTreeElement.select(); @@ -214,6 +264,8 @@ WebInspector.ProfilesPanel.prototype = { profile._profilesTreeElement = profileTreeElement; sidebarParent.appendChild(profileTreeElement); + if (!this.visibleView) + this.showProfile(profile); }, showProfile: function(profile) @@ -224,7 +276,7 @@ WebInspector.ProfilesPanel.prototype = { if (this.visibleView) this.visibleView.hide(); - var view = this.profileViewForProfile(profile); + var view = profile.viewForProfile(); view.show(this.profileViews); @@ -245,18 +297,28 @@ WebInspector.ProfilesPanel.prototype = { this.showProfile(view.profile); }, - profileViewForProfile: function(profile) + getProfileType: function(typeId) { - if (!profile) - return null; - if (!profile._profileView) - profile._profileView = new WebInspector.ProfileView(profile); - return profile._profileView; + return this._profileTypesByIdMap[typeId]; }, - showProfileById: function(uid) + showProfileForURL: function(url) { - this.showProfile(this._profilesIdMap[uid]); + var match = url.match(WebInspector.ProfileType.URLRegExp); + if (!match) + return; + this.showProfile(this._profilesIdMap[this._makeKey(match[3], match[1])]); + }, + + updateProfileTypeButtons: function() + { + for (var typeId in this._profileTypeButtonsByIdMap) { + var buttonElement = this._profileTypeButtonsByIdMap[typeId]; + var profileType = this.getProfileType(typeId); + buttonElement.className = profileType.buttonStyle; + buttonElement.title = profileType.buttonTooltip; + // FIXME: Apply profileType.buttonCaption once captions are added to button controls. + } }, closeVisibleView: function() @@ -266,16 +328,17 @@ WebInspector.ProfilesPanel.prototype = { delete this.visibleView; }, - displayTitleForProfileLink: function(title) + displayTitleForProfileLink: function(title, typeId) { title = unescape(title); if (title.indexOf(UserInitiatedProfileName) === 0) { title = WebInspector.UIString("Profile %d", title.substring(UserInitiatedProfileName.length + 1)); } else { - if (!(title in this._profileGroupsForLinks)) - this._profileGroupsForLinks[title] = 0; + var titleKey = this._makeKey(title, typeId); + if (!(titleKey in this._profileGroupsForLinks)) + this._profileGroupsForLinks[titleKey] = 0; - groupNumber = ++this._profileGroupsForLinks[title]; + groupNumber = ++this._profileGroupsForLinks[titleKey]; if (groupNumber > 2) // The title is used in the console message announcing that a profile has started so it gets @@ -296,7 +359,7 @@ WebInspector.ProfilesPanel.prototype = { var profilesLength = this._profiles.length; for (var i = 0; i < profilesLength; ++i) { - var view = this.profileViewForProfile(this._profiles[i]); + var view = this._profiles[i].viewForProfile(); if (!view.performSearch || view === visibleView) continue; views.push(view); @@ -323,19 +386,6 @@ WebInspector.ProfilesPanel.prototype = { } }, - setRecordingProfile: function(isProfiling) - { - this.recording = isProfiling; - - if (isProfiling) { - this.recordButton.toggled = true; - this.recordButton.title = WebInspector.UIString("Stop profiling."); - } else { - this.recordButton.toggled = false; - this.recordButton.title = WebInspector.UIString("Start profiling."); - } - }, - resize: function() { var visibleView = this.visibleView; @@ -345,39 +395,24 @@ WebInspector.ProfilesPanel.prototype = { _updateInterface: function() { + // FIXME: Replace ProfileType-specific button visibility changes by a single ProfileType-agnostic "combo-button" visibility change. if (InspectorController.profilerEnabled()) { this.enableToggleButton.title = WebInspector.UIString("Profiling enabled. Click to disable."); this.enableToggleButton.toggled = true; - this.recordButton.visible = true; - if (Preferences.heapProfilerPresent) - this.snapshotButton.visible = true; + for (var typeId in this._profileTypeButtonsByIdMap) + this._profileTypeButtonsByIdMap[typeId].removeStyleClass("hidden"); this.profileViewStatusBarItemsContainer.removeStyleClass("hidden"); this.panelEnablerView.visible = false; } else { this.enableToggleButton.title = WebInspector.UIString("Profiling disabled. Click to enable."); this.enableToggleButton.toggled = false; - this.recordButton.visible = false; - this.snapshotButton.visible = false; + for (var typeId in this._profileTypeButtonsByIdMap) + this._profileTypeButtonsByIdMap[typeId].addStyleClass("hidden"); this.profileViewStatusBarItemsContainer.addStyleClass("hidden"); this.panelEnablerView.visible = true; } }, - _recordClicked: function() - { - this.recording = !this.recording; - - if (this.recording) - InspectorController.startProfiling(); - else - InspectorController.stopProfiling(); - }, - - _snapshotClicked: function() - { - InspectorController.takeHeapSnapshot(); - }, - _enableProfiling: function() { if (InspectorController.profilerEnabled()) @@ -397,19 +432,19 @@ WebInspector.ProfilesPanel.prototype = { { // FIXME: This code needs to be adjusted when more profiling types are added. // Currently defaults to CPU profiles. - var cpuProfiles = this.sidebarTree.children[0]; + var cpuProfiles = this.getProfileType(WebInspector.CPUProfileType.TypeId).treeElement; if (cpuProfiles.children.length) return; - var profiles = InspectorController.profiles(); - var profilesLength = profiles.length; - for (var i = 0; i < profilesLength; ++i) { - var profile = profiles[i]; - this.addProfile(profile); + function populateCallback(profileHeaders) { + profileHeaders.sort(function(a, b) { return a.uid - b.uid; }); + var profileHeadersLength = profileHeaders.length; + for (var i = 0; i < profileHeadersLength; ++i) + WebInspector.addProfileHeader(profileHeaders[i]); } - if (cpuProfiles.children[0]) - cpuProfiles.children[0].select(); + var callId = WebInspector.Callback.wrap(populateCallback); + InspectorController.getProfileHeaders(callId); delete this._shouldPopulateProfiles; }, @@ -535,3 +570,6 @@ WebInspector.ProfileGroupSidebarTreeElement.prototype = { } WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; + +WebInspector.didGetProfileHeaders = WebInspector.Callback.processCallback; +WebInspector.didGetProfile = WebInspector.Callback.processCallback; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js index 4fcc956..28586f6 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourceView.js @@ -197,6 +197,7 @@ WebInspector.ResourceView.prototype = { var title = "<div class=\"header-name\"> </div>"; title += "<div class=\"raw-form-data header-value\">" + formData.escapeHTML() + "</div>"; var parmTreeElement = new TreeElement(title, null, false); + parmTreeElement.selectable = false; this.requestPayloadTreeElement.appendChild(parmTreeElement); }, diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js index 2c96974..0f873e7 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js @@ -71,6 +71,10 @@ WebInspector.ResourcesPanel = function() this.dividersElement = document.createElement("div"); this.dividersElement.id = "resources-dividers"; this.containerContentElement.appendChild(this.dividersElement); + + this.eventDividersElement = document.createElement("div"); + this.eventDividersElement.id = "resources-event-dividers"; + this.containerContentElement.appendChild(this.eventDividersElement); this.dividersLabelBarElement = document.createElement("div"); this.dividersLabelBarElement.id = "resources-dividers-label-bar"; @@ -133,8 +137,12 @@ WebInspector.ResourcesPanel = function() this.enableToggleButton.addEventListener("click", this._toggleResourceTracking.bind(this), false); this.largerResourcesButton = new WebInspector.StatusBarButton(WebInspector.UIString("Use small resource rows."), "resources-larger-resources-status-bar-item"); - this.largerResourcesButton.toggled = true; + this.largerResourcesButton.toggled = Preferences.resourcesLargeRows; this.largerResourcesButton.addEventListener("click", this._toggleLargerResources.bind(this), false); + if (!Preferences.resourcesLargeRows) { + Preferences.resourcesLargeRows = !Preferences.resourcesLargeRows; + this._toggleLargerResources(); // this will toggle the preference back to the original + } this.sortingSelectElement = document.createElement("select"); this.sortingSelectElement.className = "status-bar-item"; @@ -204,6 +212,37 @@ WebInspector.ResourcesPanel.prototype = { { return WebInspector.UIString("Resources"); }, + + get mainResourceLoadTime() + { + return this._mainResourceLoadTime || -1; + }, + + set mainResourceLoadTime(x) + { + if (this._mainResourceLoadTime === x) + return; + + this._mainResourceLoadTime = x; + + // Update the dividers to draw the new line + this._updateGraphDividersIfNeeded(true); + }, + + get mainResourceDOMContentTime() + { + return this._mainResourceDOMContentTime || -1; + }, + + set mainResourceDOMContentTime(x) + { + if (this._mainResourceDOMContentTime === x) + return; + + this._mainResourceDOMContentTime = x; + + this._updateGraphDividersIfNeeded(true); + }, get statusBarItems() { @@ -451,6 +490,9 @@ WebInspector.ResourcesPanel.prototype = { this._resources = []; this._staleResources = []; + + this.mainResourceLoadTime = -1; + this.mainResourceDOMContentTime = -1; this.resourcesTreeElement.removeChildren(); this.viewsContainerElement.removeChildren(); @@ -702,6 +744,7 @@ WebInspector.ResourcesPanel.prototype = { this._currentDividerSlice = slice; this.dividersElement.removeChildren(); + this.eventDividersElement.removeChildren(); this.dividersLabelBarElement.removeChildren(); for (var i = 1; i <= dividerCount; ++i) { @@ -721,6 +764,43 @@ WebInspector.ResourcesPanel.prototype = { this.dividersLabelBarElement.appendChild(divider); } + + if (this.calculator.startAtZero) { + // If our current sorting method starts at zero, that means it shows all + // resources starting at the same point, and so onLoad event and DOMContent + // event lines really wouldn't make much sense here, so don't render them. + return; + } + + if (this.mainResourceLoadTime !== -1) { + var percent = this.calculator.computePercentageFromEventTime(this.mainResourceLoadTime); + + var loadDivider = document.createElement("div"); + loadDivider.className = "resources-onload-divider"; + + var loadDividerPadding = document.createElement("div"); + loadDividerPadding.className = "resources-event-divider-padding"; + loadDividerPadding.style.left = percent + "%"; + loadDividerPadding.title = WebInspector.UIString("Load event fired"); + loadDividerPadding.appendChild(loadDivider); + + this.eventDividersElement.appendChild(loadDividerPadding); + } + + if (this.mainResourceDOMContentTime !== -1) { + var percent = this.calculator.computePercentageFromEventTime(this.mainResourceDOMContentTime); + + var domContentDivider = document.createElement("div"); + domContentDivider.className = "resources-ondomcontent-divider"; + + var domContentDividerPadding = document.createElement("div"); + domContentDividerPadding.className = "resources-event-divider-padding"; + domContentDividerPadding.style.left = percent + "%"; + domContentDividerPadding.title = WebInspector.UIString("DOMContent event fired"); + domContentDividerPadding.appendChild(domContentDivider); + + this.eventDividersElement.appendChild(domContentDividerPadding); + } }, _updateSummaryGraph: function() @@ -733,6 +813,7 @@ WebInspector.ResourcesPanel.prototype = { var scrollTop = this.containerElement.scrollTop; var dividersTop = (scrollTop < this.summaryBar.element.offsetHeight ? this.summaryBar.element.offsetHeight : scrollTop); this.dividersElement.style.top = scrollTop + "px"; + this.eventDividersElement.style.top = scrollTop + "px"; this.dividersLabelBarElement.style.top = dividersTop + "px"; }, @@ -766,6 +847,8 @@ WebInspector.ResourcesPanel.prototype = { return; this.resourcesTreeElement.smallChildren = !this.resourcesTreeElement.smallChildren; + Preferences.resourcesLargeRows = !Preferences.resourcesLargeRows; + InspectorController.setSetting("resources-large-rows", Preferences.resourcesLargeRows); if (this.resourcesTreeElement.smallChildren) { this.resourcesGraphsElement.addStyleClass("small"); @@ -1048,6 +1131,17 @@ WebInspector.ResourceTimeCalculator.prototype = { return {start: start, middle: middle, end: end}; }, + + computePercentageFromEventTime: function(eventTime) + { + // This function computes a percentage in terms of the total loading time + // of a specific event. If startAtZero is set, then this is useless, and we + // want to return 0. + if (eventTime !== -1 && !this.startAtZero) + return ((eventTime - this.minimumBoundary) / this.boundarySpan) * 100; + + return 0; + }, computeBarGraphLabels: function(resource) { @@ -1193,13 +1287,12 @@ WebInspector.ResourceSidebarTreeElement.prototype = { { WebInspector.SidebarTreeElement.prototype.onattach.call(this); - var link = document.createElement("a"); - link.href = this.resource.url; - link.className = "invisible"; - while (this._listItemNode.firstChild) - link.appendChild(this._listItemNode.firstChild); - this._listItemNode.appendChild(link); this._listItemNode.addStyleClass("resources-category-" + this.resource.category.name); + this._listItemNode.draggable = true; + + // FIXME: should actually add handler to parent, to be resolved via + // https://bugs.webkit.org/show_bug.cgi?id=30227 + this._listItemNode.addEventListener("dragstart", this.ondragstart.bind(this), false); }, onselect: function() @@ -1212,6 +1305,13 @@ WebInspector.ResourceSidebarTreeElement.prototype = { InjectedScriptAccess.openInInspectedWindow(this.resource.url, function() {}); }, + ondragstart: function(event) { + event.dataTransfer.setData("text/plain", this.resource.url); + event.dataTransfer.setData("text/uri-list", this.resource.url + "\r\n"); + event.dataTransfer.effectAllowed = "copy"; + return true; + }, + get mainTitle() { return this.resource.displayName; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ScopeChainSidebarPane.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ScopeChainSidebarPane.js index 3875324..fdfcd38 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ScopeChainSidebarPane.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ScopeChainSidebarPane.js @@ -55,14 +55,16 @@ WebInspector.ScopeChainSidebarPane.prototype = { var extraProperties = null; if (scopeObjectProxy.isLocal) { - if (scopeObjectProxy.thisObject) { + foundLocalScope = true; + title = WebInspector.UIString("Local"); + emptyPlaceholder = WebInspector.UIString("No Variables"); + subtitle = null; + if (scopeObjectProxy.thisObject) extraProperties = [ new WebInspector.ObjectPropertyProxy("this", scopeObjectProxy.thisObject) ]; - title = WebInspector.UIString("Local"); - } else - title = WebInspector.UIString("Closure"); + } else if (scopeObjectProxy.isClosure) { + title = WebInspector.UIString("Closure"); emptyPlaceholder = WebInspector.UIString("No Variables"); subtitle = null; - foundLocalScope = true; } else if (i === (scopeChain.length - 1)) title = WebInspector.UIString("Global"); else if (scopeObjectProxy.isElement) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js index ae918d1..4aa0ab2 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js @@ -359,7 +359,7 @@ WebInspector.ScriptsPanel.prototype = { return selectedCallFrame.id; }, - evaluateInSelectedCallFrame: function(code, updateInterface, callback) + evaluateInSelectedCallFrame: function(code, updateInterface, objectGroup, callback) { var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame; if (!this._paused || !selectedCallFrame) @@ -375,33 +375,17 @@ WebInspector.ScriptsPanel.prototype = { if (updateInterface) self.sidebarPanes.scopechain.update(selectedCallFrame); } - this.doEvalInCallFrame(selectedCallFrame, code, updatingCallbackWrapper); + this.doEvalInCallFrame(selectedCallFrame, code, objectGroup, updatingCallbackWrapper); }, - doEvalInCallFrame: function(callFrame, code, callback) + doEvalInCallFrame: function(callFrame, code, objectGroup, callback) { function evalCallback(result) { if (result) callback(result.value, result.isException); } - InjectedScriptAccess.evaluateInCallFrame(callFrame.id, code, evalCallback); - }, - - variablesInSelectedCallFrame: function() - { - var selectedCallFrame = this.sidebarPanes.callstack.selectedCallFrame; - if (!this._paused || !selectedCallFrame) - return {}; - - var result = {}; - var scopeChain = selectedCallFrame.scopeChain; - for (var i = 0; i < scopeChain.length; ++i) { - var scopeObjectProperties = scopeChain[i].properties; - for (var j = 0; j < scopeObjectProperties.length; ++j) - result[scopeObjectProperties[j]] = true; - } - return result; + InjectedScriptAccess.evaluateInCallFrame(callFrame.id, code, objectGroup, evalCallback); }, debuggerPaused: function(callFrames) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js index e364cb2..790055a 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Joseph Pecoraro * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -216,12 +217,18 @@ WebInspector.SourceFrame.prototype = { headElement = this.element.contentDocument.createElement("head"); this.element.contentDocument.documentElement.insertBefore(headElement, this.element.contentDocument.documentElement.firstChild); } + + var linkElement = this.element.contentDocument.createElement("link"); + linkElement.type = "text/css"; + linkElement.rel = "stylesheet"; + linkElement.href = "inspectorSyntaxHighlight.css"; + headElement.appendChild(linkElement); var styleElement = this.element.contentDocument.createElement("style"); headElement.appendChild(styleElement); // Add these style rules here since they are specific to the Inspector. They also behave oddly and not - // all properties apply if added to view-source.css (becuase it is a user agent sheet.) + // all properties apply if added to view-source.css (because it is a user agent sheet.) var styleText = ".webkit-line-number { background-repeat: no-repeat; background-position: right 1px; }\n"; styleText += ".webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(program-counter); }\n"; @@ -240,10 +247,6 @@ WebInspector.SourceFrame.prototype = { styleText += ".webkit-line-content { background-color: white; }\n"; styleText += "@-webkit-keyframes fadeout {from {background-color: rgb(255, 255, 120);} to { background-color: white;}}\n"; styleText += ".webkit-highlighted-line .webkit-line-content { background-color: rgb(255, 255, 120); -webkit-animation: 'fadeout' 2s 500ms}\n"; - styleText += ".webkit-javascript-comment { color: rgb(0, 116, 0); }\n"; - styleText += ".webkit-javascript-keyword { color: rgb(170, 13, 145); }\n"; - styleText += ".webkit-javascript-number { color: rgb(28, 0, 207); }\n"; - styleText += ".webkit-javascript-string, .webkit-javascript-regexp { color: rgb(196, 26, 22); }\n"; // TODO: Move these styles into inspector.css once https://bugs.webkit.org/show_bug.cgi?id=28913 is fixed and popup moved into the top frame. styleText += ".popup-content { position: absolute; z-index: 10000; padding: 4px; background-color: rgb(203, 226, 255); -webkit-border-radius: 7px; border: 2px solid rgb(169, 172, 203); }"; @@ -253,7 +256,7 @@ WebInspector.SourceFrame.prototype = { styleText += ".popup-content input#bp-condition { font-family: monospace; margin: 0; border: 1px inset rgb(190, 190, 190) !important; width: 100%; box-shadow: none !important; outline: none !important; -webkit-user-modify: read-write; }"; // This class is already in inspector.css styleText += ".hidden { display: none !important; }"; - + styleElement.textContent = styleText; this._needsProgramCounterImage = true; @@ -311,11 +314,11 @@ WebInspector.SourceFrame.prototype = { var sourceRow = event.target.enclosingNodeOrSelfWithNodeName("tr"); if (!sourceRow._breakpointObject && this.addBreakpointDelegate) this.addBreakpointDelegate(this.lineNumberForSourceRow(sourceRow)); - + var breakpoint = sourceRow._breakpointObject; if (!breakpoint) return; - + this._editBreakpointCondition(event.target, sourceRow, breakpoint); event.preventDefault(); }, @@ -340,7 +343,7 @@ WebInspector.SourceFrame.prototype = { // TODO: Migrate the popup to the top-level document and remove the blur listener from conditionElement once https://bugs.webkit.org/show_bug.cgi?id=28913 is fixed. var popupDocument = this.element.contentDocument; this._showBreakpointConditionPopup(eventTarget, breakpoint.line, popupDocument); - + function committed(element, newText) { breakpoint.condition = newText; @@ -359,7 +362,7 @@ WebInspector.SourceFrame.prototype = { var dismissedHandler = dismissed.bind(this); this._conditionEditorElement.addEventListener("blur", dismissedHandler, false); - + WebInspector.startEditing(this._conditionEditorElement, committed.bind(this), dismissedHandler); this._conditionEditorElement.value = breakpoint.condition; this._conditionEditorElement.select(); @@ -716,191 +719,394 @@ WebInspector.SourceFrame.prototype = { if (!table) return; - function deleteContinueFlags(cell) - { - if (!cell) - return; - delete cell._commentContinues; - delete cell._singleQuoteStringContinues; - delete cell._doubleQuoteStringContinues; - delete cell._regexpContinues; - } + var jsSyntaxHighlighter = new WebInspector.JavaScriptSourceSyntaxHighlighter(table, this); + jsSyntaxHighlighter.process(); + }, - function createSpan(content, className) - { - var span = document.createElement("span"); - span.className = className; - span.appendChild(document.createTextNode(content)); - return span; - } + syntaxHighlightCSS: function() + { + var table = this.element.contentDocument.getElementsByTagName("table")[0]; + if (!table) + return; - function generateFinder(regex, matchNumber, className) - { - return function(str) { - var match = regex.exec(str); - if (!match) - return null; - previousMatchLength = match[matchNumber].length; - return createSpan(match[matchNumber], className); - }; - } + var cssSyntaxHighlighter = new WebInspector.CSSSourceSyntaxHighligher(table, this); + cssSyntaxHighlighter.process(); + } +} - var findNumber = generateFinder(/^(-?(\d+\.?\d*([eE][+-]\d+)?|0[xX]\h+|Infinity)|NaN)(?:\W|$)/, 1, "webkit-javascript-number"); - var findKeyword = generateFinder(/^(null|true|false|break|case|catch|const|default|finally|for|instanceof|new|var|continue|function|return|void|delete|if|this|do|while|else|in|switch|throw|try|typeof|with|debugger|class|enum|export|extends|import|super|get|set)(?:\W|$)/, 1, "webkit-javascript-keyword"); - var findSingleLineString = generateFinder(/^"(?:[^"\\]|\\.)*"|^'([^'\\]|\\.)*'/, 0, "webkit-javascript-string"); // " this quote keeps Xcode happy - var findMultilineCommentStart = generateFinder(/^\/\*.*$/, 0, "webkit-javascript-comment"); - var findMultilineCommentEnd = generateFinder(/^.*?\*\//, 0, "webkit-javascript-comment"); - var findMultilineSingleQuoteStringStart = generateFinder(/^'(?:[^'\\]|\\.)*\\$/, 0, "webkit-javascript-string"); - var findMultilineSingleQuoteStringEnd = generateFinder(/^(?:[^'\\]|\\.)*?'/, 0, "webkit-javascript-string"); - var findMultilineDoubleQuoteStringStart = generateFinder(/^"(?:[^"\\]|\\.)*\\$/, 0, "webkit-javascript-string"); - var findMultilineDoubleQuoteStringEnd = generateFinder(/^(?:[^"\\]|\\.)*?"/, 0, "webkit-javascript-string"); - var findMultilineRegExpEnd = generateFinder(/^(?:[^\/\\]|\\.)*?\/([gim]{0,3})/, 0, "webkit-javascript-regexp"); - var findSingleLineComment = generateFinder(/^\/\/.*|^\/\*.*?\*\//, 0, "webkit-javascript-comment"); - - function findMultilineRegExpStart(str) - { - var match = /^\/(?:[^\/\\]|\\.)*\\$/.exec(str); - if (!match || !/\\|\$|\.[\?\*\+]|[^\|]\|[^\|]/.test(match[0])) +WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype; + +WebInspector.SourceSyntaxHighligher = function(table, sourceFrame) +{ + this.table = table; + this.sourceFrame = sourceFrame; +} + +WebInspector.SourceSyntaxHighligher.prototype = { + createSpan: function(content, className) + { + var span = document.createElement("span"); + span.className = className; + span.appendChild(document.createTextNode(content)); + return span; + }, + + generateFinder: function(regex, matchNumber, className) + { + return function(str) { + var match = regex.exec(str); + if (!match) return null; - var node = createSpan(match[0], "webkit-javascript-regexp"); - previousMatchLength = match[0].length; - return node; - } + this.previousMatchLength = match[matchNumber].length; + return this.createSpan(match[matchNumber], className); + }; + }, + + process: function() + { + // Split up the work into chunks so we don't block the + // UI thread while processing. + + var i = 0; + var rows = this.table.rows; + var rowsLength = rows.length; + var previousCell = null; + const linesPerChunk = 10; - function findSingleLineRegExp(str) + function processChunk() { - var match = /^(\/(?:[^\/\\]|\\.)*\/([gim]{0,3}))(.?)/.exec(str); - if (!match || !(match[2].length > 0 || /\\|\$|\.[\?\*\+]|[^\|]\|[^\|]/.test(match[1]) || /\.|;|,/.test(match[3]))) - return null; - var node = createSpan(match[1], "webkit-javascript-regexp"); - previousMatchLength = match[1].length; - return node; + for (var end = Math.min(i + linesPerChunk, rowsLength); i < end; ++i) { + var row = rows[i]; + if (!row) + continue; + var cell = row.cells[1]; + if (!cell) + continue; + this.syntaxHighlightLine(cell, previousCell); + if (i < (end - 1)) + this.deleteContinueFlags(previousCell); + previousCell = cell; + } + + if (i >= rowsLength && processChunkInterval) { + this.deleteContinueFlags(previousCell); + delete this.previousMatchLength; + clearInterval(processChunkInterval); + + this.sourceFrame.dispatchEventToListeners("syntax highlighting complete"); + } } - function syntaxHighlightJavascriptLine(line, prevLine) - { - var messageBubble = line.lastChild; - if (messageBubble && messageBubble.nodeType === Node.ELEMENT_NODE && messageBubble.hasStyleClass("webkit-html-message-bubble")) - line.removeChild(messageBubble); - else - messageBubble = null; + var boundProcessChunk = processChunk.bind(this); + var processChunkInterval = setInterval(boundProcessChunk, 25); + boundProcessChunk(); + } +} + +WebInspector.CSSSourceSyntaxHighligher = function(table, sourceFrame) { + WebInspector.SourceSyntaxHighligher.call(this, table, sourceFrame); + + this.findNumber = this.generateFinder(/^((-?(\d+|\d*\.\d+))|^(#[a-fA-F0-9]{3,6}))(?:\D|$)/, 1, "webkit-css-number"); + this.findUnits = this.generateFinder(/^(px|em|pt|in|cm|mm|pc|ex)(?:\W|$)/, 1, "webkit-css-unit"); + this.findKeyword = this.generateFinder(/^(rgba?|hsla?|var)(?:\W|$)/, 1, "webkit-css-keyword"); + this.findSingleLineString = this.generateFinder(/^"(?:[^"\\]|\\.)*"|^'([^'\\]|\\.)*'/, 0, "webkit-css-string"); // " this quote keeps Xcode happy + this.findSingleLineComment = this.generateFinder(/^\/\*.*?\*\//, 0, "webkit-css-comment"); + this.findMultilineCommentStart = this.generateFinder(/^\/\*.*$/, 0, "webkit-css-comment"); + this.findMultilineCommentEnd = this.generateFinder(/^.*?\*\//, 0, "webkit-css-comment"); + this.findSelector = this.generateFinder(/^([#\.]?[_a-zA-Z].*?)(?:\W|$)/, 1, "webkit-css-selector"); + this.findProperty = this.generateFinder(/^(-?[_a-z0-9][_a-z0-9-]*\s*)(?:\:)/, 1, "webkit-css-property"); + this.findGenericIdent = this.generateFinder(/^([@-]?[_a-z0-9][_a-z0-9-]*)(?:\W|$)/, 1, "webkit-css-string"); +} + +WebInspector.CSSSourceSyntaxHighligher.prototype = { + deleteContinueFlags: function(cell) + { + if (!cell) + return; + delete cell._commentContinues; + delete cell._inSelector; + }, + + findPseudoClass: function(str) + { + var match = /^(::?)([_a-z0-9][_a-z0-9-]*)/.exec(str); + if (!match) + return null; + this.previousMatchLength = match[0].length; + var span = document.createElement("span"); + span.appendChild(document.createTextNode(match[1])); + span.appendChild(this.createSpan(match[2], "webkit-css-pseudo-class")); + return span; + }, + + findURL: function(str) + { + var match = /^(?:local|url)\(([^\)]*?)\)/.exec(str); + if (!match) + return null; + this.previousMatchLength = match[0].length; + var innerUrlSpan = this.createSpan(match[1], "webkit-css-url"); + var outerSpan = document.createElement("span"); + outerSpan.appendChild(this.createSpan("url", "webkit-css-keyword")); + outerSpan.appendChild(document.createTextNode("(")); + outerSpan.appendChild(innerUrlSpan); + outerSpan.appendChild(document.createTextNode(")")); + return outerSpan; + }, + + findAtRule: function(str) + { + var match = /^@[_a-z0-9][_a-z0-9-]*(?:\W|$)/.exec(str); + if (!match) + return null; + this.previousMatchLength = match[0].length; + return this.createSpan(match[0], "webkit-css-at-rule"); + }, - var code = line.textContent; + syntaxHighlightLine: function(line, prevLine) + { + var code = line.textContent; + while (line.firstChild) + line.removeChild(line.firstChild); - while (line.firstChild) - line.removeChild(line.firstChild); + var token; + var tmp = 0; + var i = 0; + this.previousMatchLength = 0; - var token; - var tmp = 0; - var i = 0; - previousMatchLength = 0; + if (prevLine) { + if (prevLine._commentContinues) { + if (!(token = this.findMultilineCommentEnd(code))) { + token = this.createSpan(code, "webkit-javascript-comment"); + line._commentContinues = true; + } + } + if (token) { + i += this.previousMatchLength ? this.previousMatchLength : code.length; + tmp = i; + line.appendChild(token); + } + } - if (prevLine) { - if (prevLine._commentContinues) { - if (!(token = findMultilineCommentEnd(code))) { - token = createSpan(code, "webkit-javascript-comment"); - line._commentContinues = true; + var inSelector = (prevLine && prevLine._inSelector); // inside a selector, we can now parse properties and values + var inAtRuleBlock = (prevLine && prevLine._inAtRuleBlock); // inside an @rule block, but not necessarily inside a selector yet + var atRuleStarted = (prevLine && prevLine._atRuleStarted); // we received an @rule, we may stop the @rule at a semicolon or open a block and become inAtRuleBlock + var atRuleIsSelector = (prevLine && prevLine._atRuleIsSelector); // when this @rule opens a block it immediately goes into parsing properties and values instead of selectors + + for ( ; i < code.length; ++i) { + var codeFragment = code.substr(i); + var prevChar = code[i - 1]; + var currChar = codeFragment[0]; + token = this.findSingleLineComment(codeFragment); + if (!token) { + if ((token = this.findMultilineCommentStart(codeFragment))) + line._commentContinues = true; + else if (currChar === ";" && !inAtRuleBlock) + atRuleStarted = false; + else if (currChar === "}") { + if (inSelector && inAtRuleBlock && atRuleIsSelector) { + inSelector = false; + inAtRuleBlock = false; + atRuleStarted = false; + } else if (inSelector) { + inSelector = false; + } else if (inAtRuleBlock) { + inAtRuleBlock = false; + atRuleStarted = false; } - } else if (prevLine._singleQuoteStringContinues) { - if (!(token = findMultilineSingleQuoteStringEnd(code))) { - token = createSpan(code, "webkit-javascript-string"); - line._singleQuoteStringContinues = true; + } else if (currChar === "{") { + if (!atRuleStarted || inAtRuleBlock) { + inSelector = true; + } else if (!inAtRuleBlock && atRuleIsSelector) { + inAtRuleBlock = true; + inSelector = true; + } else if (!inAtRuleBlock) { + inAtRuleBlock = true; + inSelector = false; } - } else if (prevLine._doubleQuoteStringContinues) { - if (!(token = findMultilineDoubleQuoteStringEnd(code))) { - token = createSpan(code, "webkit-javascript-string"); - line._doubleQuoteStringContinues = true; + } else if (inSelector) { + if (!prevChar || /^\d/.test(prevChar)) { + token = this.findUnits(codeFragment); + } else if (!prevChar || /^\W/.test(prevChar)) { + token = this.findNumber(codeFragment) || + this.findKeyword(codeFragment) || + this.findURL(codeFragment) || + this.findProperty(codeFragment) || + this.findAtRule(codeFragment) || + this.findGenericIdent(codeFragment) || + this.findSingleLineString(codeFragment); } - } else if (prevLine._regexpContinues) { - if (!(token = findMultilineRegExpEnd(code))) { - token = createSpan(code, "webkit-javascript-regexp"); - line._regexpContinues = true; + } else if (!inSelector) { + if (atRuleStarted && !inAtRuleBlock) + token = this.findURL(codeFragment); // for @import + if (!token) { + token = this.findSelector(codeFragment) || + this.findPseudoClass(codeFragment) || + this.findAtRule(codeFragment); } } - if (token) { - i += previousMatchLength ? previousMatchLength : code.length; - tmp = i; - line.appendChild(token); - } } - for ( ; i < code.length; ++i) { - var codeFragment = code.substr(i); - var prevChar = code[i - 1]; - token = findSingleLineComment(codeFragment); - if (!token) { - if ((token = findMultilineCommentStart(codeFragment))) - line._commentContinues = true; - else if (!prevChar || /^\W/.test(prevChar)) { - token = findNumber(codeFragment, code[i - 1]) || - findKeyword(codeFragment, code[i - 1]) || - findSingleLineString(codeFragment) || - findSingleLineRegExp(codeFragment); - if (!token) { - if (token = findMultilineSingleQuoteStringStart(codeFragment)) - line._singleQuoteStringContinues = true; - else if (token = findMultilineDoubleQuoteStringStart(codeFragment)) - line._doubleQuoteStringContinues = true; - else if (token = findMultilineRegExpStart(codeFragment)) - line._regexpContinues = true; - } - } - } + if (token) { + if (currChar === "@") { + atRuleStarted = true; - if (token) { - if (tmp !== i) - line.appendChild(document.createTextNode(code.substring(tmp, i))); - line.appendChild(token); - i += previousMatchLength - 1; - tmp = i + 1; + // The @font-face, @page, and @variables at-rules do not contain selectors like other at-rules + // instead it acts as a selector and contains properties and values. + var text = token.textContent; + atRuleIsSelector = /font-face/.test(text) || /page/.test(text) || /variables/.test(text); } + + if (tmp !== i) + line.appendChild(document.createTextNode(code.substring(tmp, i))); + line.appendChild(token); + i += this.previousMatchLength - 1; + tmp = i + 1; } + } - if (tmp < code.length) - line.appendChild(document.createTextNode(code.substring(tmp, i))); + line._inSelector = inSelector; + line._inAtRuleBlock = inAtRuleBlock; + line._atRuleStarted = atRuleStarted; + line._atRuleIsSelector = atRuleIsSelector; - if (messageBubble) - line.appendChild(messageBubble); - } + if (tmp < code.length) + line.appendChild(document.createTextNode(code.substring(tmp, i))); + } +} - var i = 0; - var rows = table.rows; - var rowsLength = rows.length; - var previousCell = null; - var previousMatchLength = 0; - var sourceFrame = this; +WebInspector.CSSSourceSyntaxHighligher.prototype.__proto__ = WebInspector.SourceSyntaxHighligher.prototype; + +WebInspector.JavaScriptSourceSyntaxHighlighter = function(table, sourceFrame) { + WebInspector.SourceSyntaxHighligher.call(this, table, sourceFrame); + + this.findNumber = this.generateFinder(/^(-?(\d+\.?\d*([eE][+-]\d+)?|0[xX]\h+|Infinity)|NaN)(?:\W|$)/, 1, "webkit-javascript-number"); + this.findKeyword = this.generateFinder(/^(null|true|false|break|case|catch|const|default|finally|for|instanceof|new|var|continue|function|return|void|delete|if|this|do|while|else|in|switch|throw|try|typeof|with|debugger|class|enum|export|extends|import|super|get|set)(?:\W|$)/, 1, "webkit-javascript-keyword"); + this.findSingleLineString = this.generateFinder(/^"(?:[^"\\]|\\.)*"|^'([^'\\]|\\.)*'/, 0, "webkit-javascript-string"); // " this quote keeps Xcode happy + this.findMultilineCommentStart = this.generateFinder(/^\/\*.*$/, 0, "webkit-javascript-comment"); + this.findMultilineCommentEnd = this.generateFinder(/^.*?\*\//, 0, "webkit-javascript-comment"); + this.findMultilineSingleQuoteStringStart = this.generateFinder(/^'(?:[^'\\]|\\.)*\\$/, 0, "webkit-javascript-string"); + this.findMultilineSingleQuoteStringEnd = this.generateFinder(/^(?:[^'\\]|\\.)*?'/, 0, "webkit-javascript-string"); + this.findMultilineDoubleQuoteStringStart = this.generateFinder(/^"(?:[^"\\]|\\.)*\\$/, 0, "webkit-javascript-string"); + this.findMultilineDoubleQuoteStringEnd = this.generateFinder(/^(?:[^"\\]|\\.)*?"/, 0, "webkit-javascript-string"); + this.findMultilineRegExpEnd = this.generateFinder(/^(?:[^\/\\]|\\.)*?\/([gim]{0,3})/, 0, "webkit-javascript-regexp"); + this.findSingleLineComment = this.generateFinder(/^\/\/.*|^\/\*.*?\*\//, 0, "webkit-javascript-comment"); +} - // Split up the work into chunks so we don't block the - // UI thread while processing. +WebInspector.JavaScriptSourceSyntaxHighlighter.prototype = { + deleteContinueFlags: function(cell) + { + if (!cell) + return; + delete cell._commentContinues; + delete cell._singleQuoteStringContinues; + delete cell._doubleQuoteStringContinues; + delete cell._regexpContinues; + }, - function processChunk() - { - for (var end = Math.min(i + 10, rowsLength); i < end; ++i) { - var row = rows[i]; - if (!row) - continue; - var cell = row.cells[1]; - if (!cell) - continue; - syntaxHighlightJavascriptLine(cell, previousCell); - if (i < (end - 1)) - deleteContinueFlags(previousCell); - previousCell = cell; + findMultilineRegExpStart: function(str) + { + var match = /^\/(?:[^\/\\]|\\.)*\\$/.exec(str); + if (!match || !/\\|\$|\.[\?\*\+]|[^\|]\|[^\|]/.test(match[0])) + return null; + this.previousMatchLength = match[0].length; + return this.createSpan(match[0], "webkit-javascript-regexp"); + }, + + findSingleLineRegExp: function(str) + { + var match = /^(\/(?:[^\/\\]|\\.)*\/([gim]{0,3}))(.?)/.exec(str); + if (!match || !(match[2].length > 0 || /\\|\$|\.[\?\*\+]|[^\|]\|[^\|]/.test(match[1]) || /\.|;|,/.test(match[3]))) + return null; + this.previousMatchLength = match[1].length; + return this.createSpan(match[1], "webkit-javascript-regexp"); + }, + + syntaxHighlightLine: function(line, prevLine) + { + var messageBubble = line.lastChild; + if (messageBubble && messageBubble.nodeType === Node.ELEMENT_NODE && messageBubble.hasStyleClass("webkit-html-message-bubble")) + line.removeChild(messageBubble); + else + messageBubble = null; + + var code = line.textContent; + + while (line.firstChild) + line.removeChild(line.firstChild); + + var token; + var tmp = 0; + var i = 0; + this.previousMatchLength = 0; + + if (prevLine) { + if (prevLine._commentContinues) { + if (!(token = this.findMultilineCommentEnd(code))) { + token = this.createSpan(code, "webkit-javascript-comment"); + line._commentContinues = true; + } + } else if (prevLine._singleQuoteStringContinues) { + if (!(token = this.findMultilineSingleQuoteStringEnd(code))) { + token = this.createSpan(code, "webkit-javascript-string"); + line._singleQuoteStringContinues = true; + } + } else if (prevLine._doubleQuoteStringContinues) { + if (!(token = this.findMultilineDoubleQuoteStringEnd(code))) { + token = this.createSpan(code, "webkit-javascript-string"); + line._doubleQuoteStringContinues = true; + } + } else if (prevLine._regexpContinues) { + if (!(token = this.findMultilineRegExpEnd(code))) { + token = this.createSpan(code, "webkit-javascript-regexp"); + line._regexpContinues = true; + } + } + if (token) { + i += this.previousMatchLength ? this.previousMatchLength : code.length; + tmp = i; + line.appendChild(token); } + } - if (i >= rowsLength && processChunkInterval) { - deleteContinueFlags(previousCell); - clearInterval(processChunkInterval); + for ( ; i < code.length; ++i) { + var codeFragment = code.substr(i); + var prevChar = code[i - 1]; + token = this.findSingleLineComment(codeFragment); + if (!token) { + if ((token = this.findMultilineCommentStart(codeFragment))) + line._commentContinues = true; + else if (!prevChar || /^\W/.test(prevChar)) { + token = this.findNumber(codeFragment) || + this.findKeyword(codeFragment) || + this.findSingleLineString(codeFragment) || + this.findSingleLineRegExp(codeFragment); + if (!token) { + if (token = this.findMultilineSingleQuoteStringStart(codeFragment)) + line._singleQuoteStringContinues = true; + else if (token = this.findMultilineDoubleQuoteStringStart(codeFragment)) + line._doubleQuoteStringContinues = true; + else if (token = this.findMultilineRegExpStart(codeFragment)) + line._regexpContinues = true; + } + } + } - sourceFrame.dispatchEventToListeners("syntax highlighting complete"); + if (token) { + if (tmp !== i) + line.appendChild(document.createTextNode(code.substring(tmp, i))); + line.appendChild(token); + i += this.previousMatchLength - 1; + tmp = i + 1; } } - processChunk(); + if (tmp < code.length) + line.appendChild(document.createTextNode(code.substring(tmp, i))); - var processChunkInterval = setInterval(processChunk, 25); + if (messageBubble) + line.appendChild(messageBubble); } } -WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype; - +WebInspector.JavaScriptSourceSyntaxHighlighter.prototype.__proto__ = WebInspector.SourceSyntaxHighligher.prototype; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js index 97a5bd5..c1b1bbf 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js @@ -106,11 +106,16 @@ WebInspector.SourceView.prototype = { this.sourceFrame.removeEventListener("content loaded", this._contentLoaded, this); if (this.resource.type === WebInspector.Resource.Type.Script - || this.resource.mimeType === 'application/json' - || this.resource.mimeType === 'application/javascript' + || this.resource.mimeType === "application/json" + || this.resource.mimeType === "application/javascript" || /\.js(on)?$/.test(this.resource.lastPathComponent) ) { this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this); this.sourceFrame.syntaxHighlightJavascript(); + } else if (this.resource.type === WebInspector.Resource.Type.Stylesheet + || this.resource.mimeType === "text/css" + || /\.css$/.test(this.resource.lastPathComponent) ) { + this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this); + this.sourceFrame.syntaxHighlightCSS(); } else this._sourceFrameSetupFinished(); }, diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/StoragePanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/StoragePanel.js index 01c657d..66b4a92 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/StoragePanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/StoragePanel.js @@ -63,9 +63,6 @@ WebInspector.StoragePanel = function(database) this.sidebarTree.appendChild(this.cookieListTreeElement); this.cookieListTreeElement.expand(); - this.cookieTreeElement = new WebInspector.CookieSidebarTreeElement(); - this.cookieListTreeElement.appendChild(this.cookieTreeElement); - this.storageViews = document.createElement("div"); this.storageViews.id = "storage-views"; this.element.appendChild(this.storageViews); @@ -120,11 +117,14 @@ WebInspector.StoragePanel.prototype = { this._domStorage = []; - delete this._cookieView; + this._cookieDomains = {}; + this._cookieViews = {}; this.databasesListTreeElement.removeChildren(); this.localStorageListTreeElement.removeChildren(); this.sessionStorageListTreeElement.removeChildren(); + this.cookieListTreeElement.removeChildren(); + this.storageViews.removeChildren(); this.storageViewStatusBarItemsContainer.removeChildren(); @@ -146,6 +146,17 @@ WebInspector.StoragePanel.prototype = { database._databasesTreeElement = databaseTreeElement; this.databasesListTreeElement.appendChild(databaseTreeElement); }, + + addCookieDomain: function(domain) + { + // Eliminate duplicate domains from the list. + if (typeof this._cookieDomains[domain] !== "undefined") + return; + + var cookieDomainTreeElement = new WebInspector.CookieSidebarTreeElement(domain); + this.cookieListTreeElement.appendChild(cookieDomainTreeElement); + this._cookieDomains[domain] = true; + }, addDOMStorage: function(domStorage) { @@ -158,12 +169,12 @@ WebInspector.StoragePanel.prototype = { this.sessionStorageListTreeElement.appendChild(domStorageTreeElement); }, - selectDatabase: function(db) + selectDatabase: function(databaseId) { var database; for (var i = 0, len = this._databases.length; i < len; ++i) { database = this._databases[i]; - if (database.isDatabase(db)) { + if (database.id === databaseId) { this.showDatabase(database); database._databasesTreeElement.select(); return; @@ -240,15 +251,15 @@ WebInspector.StoragePanel.prototype = { this.storageViewStatusBarItemsContainer.appendChild(statusBarItems[i]); }, - showCookies: function() + showCookies: function(cookieDomain) { if (this.visibleView) this.visibleView.hide(); - var view = this._cookieView; + var view = this._cookieViews[cookieDomain]; if (!view) { - view = new WebInspector.CookieItemsView(); - this._cookieView = view; + view = new WebInspector.CookieItemsView(cookieDomain); + this._cookieViews[cookieDomain] = view; } view.show(this.storageViews); @@ -297,20 +308,21 @@ WebInspector.StoragePanel.prototype = { database.getTableNames(tableNamesCallback); }, - dataGridForResult: function(result) + dataGridForResult: function(rows) { - if (!result.rows.length) + if (!rows.length) return null; var columns = {}; + var numColumns = 0; - var rows = result.rows; - for (var columnIdentifier in rows.item(0)) { + for (var columnIdentifier in rows[0]) { var column = {}; column.width = columnIdentifier.length; column.title = columnIdentifier; columns[columnIdentifier] = column; + ++numColumns; } var nodes = []; @@ -318,12 +330,9 @@ WebInspector.StoragePanel.prototype = { for (var i = 0; i < length; ++i) { var data = {}; - var row = rows.item(i); + var row = rows[i]; for (var columnIdentifier in row) { - // FIXME: (Bug 19439) We should specially format SQL NULL here - // (which is represented by JavaScript null here, and turned - // into the string "null" by the String() function). - var text = String(row[columnIdentifier]); + var text = row[columnIdentifier]; data[columnIdentifier] = text; if (text.length > columns[columnIdentifier].width) columns[columnIdentifier].width = text.length; @@ -339,7 +348,7 @@ WebInspector.StoragePanel.prototype = { totalColumnWidths += columns[columnIdentifier].width; // Calculate the percentage width for the columns. - const minimumPrecent = 5; + const minimumPrecent = Math.min(5, Math.floor(100/numColumns)); var recoupPercent = 0; for (var columnIdentifier in columns) { var width = columns[columnIdentifier].width; @@ -549,7 +558,7 @@ WebInspector.DOMStorageSidebarTreeElement.prototype = { get mainTitle() { - return this.domStorage.domain; + return this.domStorage.domain ? this.domStorage.domain : WebInspector.UIString("Local Files"); }, set mainTitle(x) @@ -570,9 +579,10 @@ WebInspector.DOMStorageSidebarTreeElement.prototype = { WebInspector.DOMStorageSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype; -WebInspector.CookieSidebarTreeElement = function() +WebInspector.CookieSidebarTreeElement = function(cookieDomain) { - WebInspector.SidebarTreeElement.call(this, "cookie-sidebar-tree-item", null, "", null, false); + WebInspector.SidebarTreeElement.call(this, "cookie-sidebar-tree-item", cookieDomain, "", null, false); + this._cookieDomain = cookieDomain; this.refreshTitles(); } @@ -580,12 +590,12 @@ WebInspector.CookieSidebarTreeElement = function() WebInspector.CookieSidebarTreeElement.prototype = { onselect: function() { - WebInspector.panels.storage.showCookies(); + WebInspector.panels.storage.showCookies(this._cookieDomain); }, - + get mainTitle() { - return WebInspector.UIString("Cookies"); + return this._cookieDomain ? this._cookieDomain : WebInspector.UIString("Local Files"); }, set mainTitle(x) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/TestController.js b/src/3rdparty/webkit/WebCore/inspector/front-end/TestController.js new file mode 100644 index 0000000..8da59e7 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/TestController.js @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 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. + */ + +WebInspector.TestController = function(callId) +{ + this._callId = callId; + this._waitUntilDone = false; +} + +WebInspector.TestController.prototype = { + waitUntilDone: function() + { + this._waitUntilDone = true; + }, + + notifyDone: function(result) + { + var message = typeof result === "undefined" ? "<undefined>" : JSON.stringify(result); + InspectorController.didEvaluateForTestInFrontend(this._callId, message); + } +} + +WebInspector.evaluateForTestInFrontend = function(callId, script) +{ + var controller = new WebInspector.TestController(callId); + try { + var result; + if (window[script] && typeof window[script] === "function") + result = window[script].call(this, controller); + else + result = window.eval(script); + + if (!controller._waitUntilDone) + controller.notifyDone(result); + } catch (e) { + controller.notifyDone(e.toString()); + } +} diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/TextPrompt.js b/src/3rdparty/webkit/WebCore/inspector/front-end/TextPrompt.js index 5ff774f..f73ab0d 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/TextPrompt.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/TextPrompt.js @@ -252,7 +252,7 @@ WebInspector.TextPrompt.prototype = { foundNextText = true; } - node = node.traverseNextNode(false, this.element); + node = node.traverseNextNode(this.element); } return true; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/TimelineAgent.js b/src/3rdparty/webkit/WebCore/inspector/front-end/TimelineAgent.js index 6d18732..4363da8 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/TimelineAgent.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/TimelineAgent.js @@ -45,10 +45,10 @@ WebInspector.addItemToTimeline = function(record) { // Not implemented. } -WebInspector.timelineWasEnabled = function() { +WebInspector.timelineProfilerWasStarted = function() { // Not implemented. } -WebInspector.timelineWasDisabled = function() { +WebInspector.timelineProfilerWasStopped = function() { // Not implemented. } diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js b/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js index d6d1d61..96a20ab 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js @@ -75,6 +75,8 @@ WebInspector.WatchExpressionsSection = function() this.editable = true; this.expanded = true; this.propertiesElement.addStyleClass("watch-expressions"); + + this._watchObjectGroupId = "watch-group"; } WebInspector.WatchExpressionsSection.NewWatchExpression = "\xA0"; @@ -114,6 +116,7 @@ WebInspector.WatchExpressionsSection.prototype = { this.updateProperties(properties, WebInspector.WatchExpressionTreeElement, WebInspector.WatchExpressionsSection.CompareProperties); } + InspectorController.releaseWrapperObjectGroup(this._watchObjectGroupId) var properties = []; // Count the properties, so we known when to call this.updateProperties() @@ -129,10 +132,10 @@ WebInspector.WatchExpressionsSection.prototype = { // which is checked in the appendResult inner function. for (var i = 0; i < this.watchExpressions.length; ++i) { var expression = this.watchExpressions[i]; - if (!expression) + if (!expression) continue; - WebInspector.console.evalInInspectedWindow("(" + expression + ")", appendResult.bind(this, expression, i)); + WebInspector.console.evalInInspectedWindow("(" + expression + ")", this._watchObjectGroupId, appendResult.bind(this, expression, i)); } // note this is setting the expansion of the tree, not the section; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc b/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc index 1aaeb3d..32f15ce 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/WebKit.qrc @@ -57,6 +57,7 @@ <file>StoragePanel.js</file> <file>StylesSidebarPane.js</file> <file>SummaryBar.js</file> + <file>TestController.js</file> <file>TextPrompt.js</file> <file>TimelineAgent.js</file> <file>TopDownProfileDataGridTree.js</file> @@ -65,6 +66,7 @@ <file>View.js</file> <file>WatchExpressionsSidebarPane.js</file> <file>inspector.css</file> + <file>inspectorSyntaxHighlight.css</file> <file>Images/back.png</file> <file>Images/checker.png</file> <file>Images/clearConsoleButtonGlyph.png</file> diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css index 358c13c..fc08bc2 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css @@ -211,7 +211,7 @@ body.attached #search-results-matches { background-image: url(Images/profilesIcon.png); } -#close-button { +#close-button-left, #close-button-right { width: 14px; height: 14px; background-image: url(Images/closeButtons.png); @@ -221,19 +221,27 @@ body.attached #search-results-matches { margin: 5px 0; } -#close-button:hover { +#close-button-left:hover, #close-button-right:hover { background-position: 14px 0; } -#close-button:active { +#close-button-left:active, #close-button-right:active { background-position: 28px 0; } -body.detached .toolbar-item.close { +body.detached .toolbar-item.close-left, body.detached .toolbar-item.close-right { display: none; } -body.attached.platform-qt .toolbar-item.close { +body.attached.platform-qt .toolbar-item.close-left, body.attached.platform-qt .toolbar-item.close-right { + display: none; +} + +body.platform-mac-tiger .toolbar-item.close-right, body.platform-mac-leopard .toolbar-item.close-right { + display: none; +} + +body:not(.platform-mac-tiger):not(.platform-mac-leopard) .toolbar-item.close-left { display: none; } @@ -818,11 +826,6 @@ body.drawer-visible #drawer { vertical-align: top; } -.invisible { - color: inherit; - text-decoration: none; -} - .webkit-line-gutter-backdrop { /* Keep this in sync with view-source.css (.webkit-line-gutter-backdrop) */ width: 31px; @@ -1637,6 +1640,10 @@ li.editing .swatch, li.editing .enabled-button, li.editing-sub-part .delete-but background-position: -46px 0px; } +.pane > .title > select > option, .pane > .title > select > hr { + color: black; +} + .pane > .body { position: relative; display: none; @@ -2512,6 +2519,7 @@ button.enable-toggle-status-bar-item.toggled-on .glyph { -webkit-background-size: 1px 6px; -webkit-background-origin: padding; -webkit-background-clip: padding; + z-index: 400; } .summary-graph-legend { @@ -2558,6 +2566,16 @@ button.enable-toggle-status-bar-item.toggled-on .glyph { z-index: -100; } +#resources-event-dividers { + position: absolute; + left: 0; + right: 0; + height: 100%; + top: 0; + z-index: 300; + pointer-events: none; +} + #resources-dividers-label-bar { position: absolute; top: 93px; @@ -2578,6 +2596,32 @@ button.enable-toggle-status-bar-item.toggled-on .glyph { background-color: rgba(0, 0, 0, 0.1); } +.resources-event-divider-padding { + position: absolute; + width: 8px; + top: 0; + bottom: 0; + pointer-events: auto; +} + +.resources-onload-divider { + position: absolute; + width: 2px; + top: 0; + bottom: 0; + z-index: 300; + background-color: rgba(255, 0, 0, 0.5); +} + +.resources-ondomcontent-divider { + position: absolute; + width: 2px; + top: 0; + bottom: 0; + z-index: 300; + background-color: rgba(0, 0, 255, 0.5); +} + .resources-divider.last { background-color: transparent; } @@ -3404,3 +3448,7 @@ ol.breakpoint-list { .breakpoint-list a:hover { color: rgb(15%, 15%, 15%); } + +.webkit-html-js-node, .webkit-html-css-node { + white-space: pre; +} diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html index f54e302..4fa69e0 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html @@ -30,6 +30,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="inspector.css"> + <link rel="stylesheet" type="text/css" href="inspectorSyntaxHighlight.css"> <script type="text/javascript" src="utilities.js"></script> <script type="text/javascript" src="treeoutline.js"></script> <script type="text/javascript" src="inspector.js"></script> @@ -93,13 +94,15 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <script type="text/javascript" src="InjectedScript.js"></script> <script type="text/javascript" src="InjectedScriptAccess.js"></script> <script type="text/javascript" src="TimelineAgent.js"></script> + <script type="text/javascript" src="TestController.js"></script> </head> <body class="detached"> <div id="toolbar"> - <div class="toolbar-item close"><button id="close-button"></button></div> + <div class="toolbar-item close-left"><button id="close-button-left"></button></div> <div class="toolbar-item flexable-space"></div> <div class="toolbar-item hidden" id="search-results-matches"></div> <div class="toolbar-item"><input id="search" type="search" incremental results="0"><div id="search-toolbar-label" class="toolbar-label"></div></div> + <div class="toolbar-item close-right"><button id="close-button-right"></button></div> </div> <div id="main"> <div id="main-panels" tabindex="0" spellcheck="false"></div> diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js index de4f4fb..17b02a1 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js @@ -29,7 +29,6 @@ */ var Preferences = { - ignoreWhitespace: true, showUserAgentStyles: true, maxInlineTextChildLength: 80, minConsoleHeight: 75, @@ -43,7 +42,8 @@ var Preferences = { samplingCPUProfiler: false, showColorNicknames: true, colorFormat: "hex", - eventListenersFilter: "all" + eventListenersFilter: "all", + resourcesLargeRows: true } var WebInspector = { @@ -139,12 +139,29 @@ var WebInspector = { this.panels.resources = new WebInspector.ResourcesPanel(); if (hiddenPanels.indexOf("scripts") === -1) this.panels.scripts = new WebInspector.ScriptsPanel(); - if (hiddenPanels.indexOf("profiles") === -1) + if (hiddenPanels.indexOf("profiles") === -1) { this.panels.profiles = new WebInspector.ProfilesPanel(); + this.panels.profiles.registerProfileType(new WebInspector.CPUProfileType()); + } if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1) this.panels.storage = new WebInspector.StoragePanel(); }, + _loadPreferences: function() + { + var colorFormat = InspectorController.setting("color-format"); + if (colorFormat) + Preferences.colorFormat = colorFormat; + + var eventListenersFilter = InspectorController.setting("event-listeners-filter"); + if (eventListenersFilter) + Preferences.eventListenersFilter = eventListenersFilter; + + var resourcesLargeRows = InspectorController.setting("resources-large-rows"); + if (typeof resourcesLargeRows !== "undefined") + Preferences.resourcesLargeRows = resourcesLargeRows; + }, + get attached() { return this._attached; @@ -351,13 +368,7 @@ WebInspector.loaded = function() var platform = InspectorController.platform(); document.body.addStyleClass("platform-" + platform); - var colorFormat = InspectorController.setting("color-format"); - if (colorFormat) - Preferences.colorFormat = colorFormat; - - var eventListenersFilter = InspectorController.setting("event-listeners-filter"); - if (eventListenersFilter) - Preferences.eventListenersFilter = eventListenersFilter; + this._loadPreferences(); this.drawer = new WebInspector.Drawer(); this.console = new WebInspector.ConsoleView(this.drawer); @@ -449,8 +460,9 @@ WebInspector.loaded = function() searchField.addEventListener("keyup", this.searchKeyUp.bind(this), false); searchField.addEventListener("search", this.performSearch.bind(this), false); // when the search is emptied - document.getElementById("toolbar").addEventListener("mousedown", this.toolbarDragStart, true); - document.getElementById("close-button").addEventListener("click", this.close, true); + toolbarElement.addEventListener("mousedown", this.toolbarDragStart, true); + document.getElementById("close-button-left").addEventListener("click", this.close, true); + document.getElementById("close-button-right").addEventListener("click", this.close, true); InspectorController.loaded(); } @@ -476,7 +488,14 @@ window.addEventListener("load", windowLoaded, false); WebInspector.dispatch = function() { var methodName = arguments[0]; var parameters = Array.prototype.slice.call(arguments, 1); - WebInspector[methodName].apply(this, parameters); + + // We'd like to enforce asynchronous interaction between the inspector controller and the frontend. + // This is important to LayoutTests. + function delayDispatch() + { + WebInspector[methodName].apply(WebInspector, parameters); + } + setTimeout(delayDispatch, 0); } WebInspector.windowUnload = function(event) @@ -537,10 +556,9 @@ WebInspector.documentClick = function(event) WebInspector.showResourceForURL(anchor.href, anchor.lineNumber, anchor.preferredPanel); } else { - var profileStringRegEx = new RegExp("webkit-profile://.+/([0-9]+)"); - var profileString = profileStringRegEx.exec(anchor.href); + var profileString = WebInspector.ProfileType.URLRegExp.exec(anchor.href); if (profileString) - WebInspector.showProfileById(profileString[1]) + WebInspector.showProfileForURL(anchor.href); } } @@ -989,6 +1007,21 @@ WebInspector.updateResource = function(identifier, payload) resource.responseReceivedTime = payload.responseReceivedTime; if (payload.endTime) resource.endTime = payload.endTime; + + if (payload.loadEventTime) { + // This loadEventTime is for the main resource, and we want to show it + // for all resources on this page. This means we want to set it as a member + // of the resources panel instead of the individual resource. + if (this.panels.resources) + this.panels.resources.mainResourceLoadTime = payload.loadEventTime; + } + + if (payload.domContentEventTime) { + // This domContentEventTime is for the main resource, so it should go in + // the resources panel for the same reasons as above. + if (this.panels.resources) + this.panels.resources.mainResourceDOMContentTime = payload.domContentEventTime; + } } } @@ -1009,13 +1042,19 @@ WebInspector.removeResource = function(identifier) WebInspector.addDatabase = function(payload) { var database = new WebInspector.Database( - payload.database, + payload.id, payload.domain, payload.name, payload.version); this.panels.storage.addDatabase(database); } +WebInspector.addCookieDomain = function(domain) +{ + if (this.panels.storage) + this.panels.storage.addCookieDomain(domain); +} + WebInspector.addDOMStorage = function(payload) { var domStorage = new WebInspector.DOMStorage( @@ -1224,14 +1263,15 @@ WebInspector.log = function(message) logMessage(message); } -WebInspector.addProfile = function(profile) +WebInspector.addProfileHeader = function(profile) { - this.panels.profiles.addProfile(profile); + this.panels.profiles.addProfileHeader(WebInspector.CPUProfileType.TypeId, new WebInspector.CPUProfile(profile)); } WebInspector.setRecordingProfile = function(isProfiling) { - this.panels.profiles.setRecordingProfile(isProfiling); + this.panels.profiles.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling); + this.panels.profiles.updateProfileTypeButtons(); } WebInspector.drawLoadingPieChart = function(canvas, percent) { @@ -1337,13 +1377,9 @@ WebInspector.linkifyStringAsFragment = function(string) var nonLink = string.substring(0, linkIndex); container.appendChild(document.createTextNode(nonLink)); - var profileStringRegEx = new RegExp("webkit-profile://(.+)/[0-9]+"); - var profileStringMatches = profileStringRegEx.exec(title); - var profileTitle; + var profileStringMatches = WebInspector.ProfileType.URLRegExp.exec(title); if (profileStringMatches) - profileTitle = profileStringMatches[1]; - if (profileTitle) - title = WebInspector.panels.profiles.displayTitleForProfileLink(profileTitle); + title = WebInspector.panels.profiles.displayTitleForProfileLink(profileStringMatches[2], profileStringMatches[1]); var realURL = (linkString.indexOf("www.") === 0 ? "http://" + linkString : linkString); container.appendChild(WebInspector.linkifyURLAsNode(realURL, title, null, (realURL in WebInspector.resourceURLMap))); @@ -1356,9 +1392,9 @@ WebInspector.linkifyStringAsFragment = function(string) return container; } -WebInspector.showProfileById = function(uid) { +WebInspector.showProfileForURL = function(url) { WebInspector.showProfilesPanel(); - WebInspector.panels.profiles.showProfileById(uid); + WebInspector.panels.profiles.showProfileForURL(url); } WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspectorSyntaxHighlight.css b/src/3rdparty/webkit/WebCore/inspector/front-end/inspectorSyntaxHighlight.css new file mode 100644 index 0000000..2cbb3c5 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspectorSyntaxHighlight.css @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Apple 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 BY APPLE AND ITS 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 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. + */ + +.webkit-css-comment { + color: rgb(0, 116, 0); +} + +.webkit-css-string, .webkit-css-keyword, .webkit-css-unit { + color: rgb(7, 144, 154); +} + +.webkit-css-number { + color: rgb(50, 0, 255); +} + +.webkit-css-property, .webkit-css-at-rule { + color: rgb(200, 0, 0); +} + +.webkit-css-url { + color: rgb(0, 0, 0); +} + +.webkit-css-selector { + color: rgb(0, 0, 0); +} + +.webkit-css-pseudo-class { + color: rgb(128, 128, 128); +} + +.webkit-javascript-comment { + color: rgb(0, 116, 0); +} + +.webkit-javascript-keyword { + color: rgb(170, 13, 145); +} + +.webkit-javascript-number { + color: rgb(28, 0, 207); +} + +.webkit-javascript-string, .webkit-javascript-regexp { + color: rgb(196, 26, 22); +} diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js b/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js index 5f41b56..6df23de 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js @@ -91,7 +91,7 @@ Node.prototype.rangeOfWord = function(offset, stopCharacters, stayWithinNode, di if (startNode) break; - node = node.traversePreviousNode(false, stayWithinNode); + node = node.traversePreviousNode(stayWithinNode); } if (!startNode) { @@ -126,7 +126,7 @@ Node.prototype.rangeOfWord = function(offset, stopCharacters, stayWithinNode, di if (endNode) break; - node = node.traverseNextNode(false, stayWithinNode); + node = node.traverseNextNode(stayWithinNode); } if (!endNode) { @@ -269,9 +269,6 @@ Element.prototype.offsetRelativeToWindow = function(targetWindow) return elementOffset; } -Element.prototype.firstChildSkippingWhitespace = firstChildSkippingWhitespace; -Element.prototype.lastChildSkippingWhitespace = lastChildSkippingWhitespace; - Node.prototype.isWhitespace = isNodeWhitespace; Node.prototype.displayName = nodeDisplayName; Node.prototype.isAncestor = function(node) @@ -279,8 +276,6 @@ Node.prototype.isAncestor = function(node) return isAncestorNode(this, node); }; Node.prototype.isDescendant = isDescendantNode; -Node.prototype.nextSiblingSkippingWhitespace = nextSiblingSkippingWhitespace; -Node.prototype.previousSiblingSkippingWhitespace = previousSiblingSkippingWhitespace; Node.prototype.traverseNextNode = traverseNextNode; Node.prototype.traversePreviousNode = traversePreviousNode; Node.prototype.onlyTextChild = onlyTextChild; @@ -455,172 +450,58 @@ function isDescendantNode(descendant) return isAncestorNode(descendant, this); } -function nextSiblingSkippingWhitespace() -{ - if (!this) - return; - var node = this.nextSibling; - while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) - node = node.nextSibling; - return node; -} - -function previousSiblingSkippingWhitespace() +function traverseNextNode(stayWithin) { if (!this) return; - var node = this.previousSibling; - while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) - node = node.previousSibling; - return node; -} -function firstChildSkippingWhitespace() -{ - if (!this) - return; var node = this.firstChild; - while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) - node = nextSiblingSkippingWhitespace.call(node); - return node; -} - -function lastChildSkippingWhitespace() -{ - if (!this) - return; - var node = this.lastChild; - while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) - node = previousSiblingSkippingWhitespace.call(node); - return node; -} - -function traverseNextNode(skipWhitespace, stayWithin) -{ - if (!this) - return; - - var node = skipWhitespace ? firstChildSkippingWhitespace.call(this) : this.firstChild; if (node) return node; if (stayWithin && this === stayWithin) return null; - node = skipWhitespace ? nextSiblingSkippingWhitespace.call(this) : this.nextSibling; + node = this.nextSibling; if (node) return node; node = this; - while (node && !(skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling) && (!stayWithin || !node.parentNode || node.parentNode !== stayWithin)) + while (node && !node.nextSibling && (!stayWithin || !node.parentNode || node.parentNode !== stayWithin)) node = node.parentNode; if (!node) return null; - return skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling; + return node.nextSibling; } -function traversePreviousNode(skipWhitespace, stayWithin) +function traversePreviousNode(stayWithin) { if (!this) return; if (stayWithin && this === stayWithin) return null; - var node = skipWhitespace ? previousSiblingSkippingWhitespace.call(this) : this.previousSibling; - while (node && (skipWhitespace ? lastChildSkippingWhitespace.call(node) : node.lastChild) ) - node = skipWhitespace ? lastChildSkippingWhitespace.call(node) : node.lastChild; + var node = this.previousSibling; + while (node && node.lastChild) + node = node.lastChild; if (node) return node; return this.parentNode; } -function onlyTextChild(ignoreWhitespace) +function onlyTextChild() { if (!this) return null; - var firstChild = ignoreWhitespace ? firstChildSkippingWhitespace.call(this) : this.firstChild; + var firstChild = this.firstChild; if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE) return null; - var sibling = ignoreWhitespace ? nextSiblingSkippingWhitespace.call(firstChild) : firstChild.nextSibling; + var sibling = firstChild.nextSibling; return sibling ? null : firstChild; } -function nodeTitleInfo(hasChildren, linkify) -{ - var info = {title: "", hasChildren: hasChildren}; - - switch (this.nodeType) { - case Node.DOCUMENT_NODE: - info.title = "Document"; - break; - - case Node.ELEMENT_NODE: - info.title = "<span class=\"webkit-html-tag\"><" + this.nodeName.toLowerCase().escapeHTML(); - - if (this.hasAttributes()) { - for (var i = 0; i < this.attributes.length; ++i) { - var attr = this.attributes[i]; - info.title += " <span class=\"webkit-html-attribute\"><span class=\"webkit-html-attribute-name\">" + attr.name.escapeHTML() + "</span>=​\""; - - var value = attr.value; - if (linkify && (attr.name === "src" || attr.name === "href")) { - var value = value.replace(/([\/;:\)\]\}])/g, "$1\u200B"); - info.title += linkify(attr.value, value, "webkit-html-attribute-value", this.nodeName.toLowerCase() == "a"); - } else { - var value = value.escapeHTML(); - value = value.replace(/([\/;:\)\]\}])/g, "$1​"); - info.title += "<span class=\"webkit-html-attribute-value\">" + value + "</span>"; - } - info.title += "\"</span>"; - } - } - info.title += "></span>​"; - - // If this element only has a single child that is a text node, - // just show that text and the closing tag inline rather than - // create a subtree for them - - var textChild = onlyTextChild.call(this, Preferences.ignoreWhitespace); - var showInlineText = textChild && textChild.textContent.length < Preferences.maxInlineTextChildLength; - - if (showInlineText) { - info.title += "<span class=\"webkit-html-text-node\">" + textChild.nodeValue.escapeHTML() + "</span>​<span class=\"webkit-html-tag\"></" + this.nodeName.toLowerCase().escapeHTML() + "></span>"; - info.hasChildren = false; - } - break; - - case Node.TEXT_NODE: - if (isNodeWhitespace.call(this)) - info.title = "(whitespace)"; - else - info.title = "\"<span class=\"webkit-html-text-node\">" + this.nodeValue.escapeHTML() + "</span>\""; - break - - case Node.COMMENT_NODE: - info.title = "<span class=\"webkit-html-comment\"><!--" + this.nodeValue.escapeHTML() + "--></span>"; - break; - - case Node.DOCUMENT_TYPE_NODE: - info.title = "<span class=\"webkit-html-doctype\"><!DOCTYPE " + this.nodeName; - if (this.publicId) { - info.title += " PUBLIC \"" + this.publicId + "\""; - if (this.systemId) - info.title += " \"" + this.systemId + "\""; - } else if (this.systemId) - info.title += " SYSTEM \"" + this.systemId + "\""; - if (this.internalSubset) - info.title += " [" + this.internalSubset + "]"; - info.title += "></span>"; - break; - default: - info.title = this.nodeName.toLowerCase().collapseWhitespace().escapeHTML(); - } - - return info; -} - function appropriateSelectorForNode(node, justSelector) { if (!node) |