diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-30 16:58:06 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-11-30 17:03:09 +0100 |
commit | 32ea33253afbbdefd2680aa95ab5f57455272ae7 (patch) | |
tree | 2389569585b666c310fbb36d3fb8e6ab94462967 /Source/WebCore/inspector | |
parent | 41c25f231cbca1babc445187283524cc6c751c71 (diff) | |
download | qtwebkit-32ea33253afbbdefd2680aa95ab5f57455272ae7.tar.gz |
Imported WebKit commit 6a4a1d32e1d779548c726c4826cba9d69eb87601 (http://svn.webkit.org/repository/webkit/trunk@136242)
Final import for the Qt 5.x series that implements the QtWebKit / QtWebKitWidgets split
Extra fixes will be cherry-picked.
Change-Id: I844f1ebb99c6d6b75db31d6538c2acd628e79681
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebCore/inspector')
18 files changed, 182 insertions, 44 deletions
diff --git a/Source/WebCore/inspector/Inspector.json b/Source/WebCore/inspector/Inspector.json index 635fa9415..a2094cbb9 100644 --- a/Source/WebCore/inspector/Inspector.json +++ b/Source/WebCore/inspector/Inspector.json @@ -1858,10 +1858,11 @@ { "name": "highlightNode", "parameters": [ - { "name": "nodeId", "$ref": "NodeId", "description": "Identifier of the node to highlight." }, + { "name": "nodeId", "$ref": "NodeId", "optional": true, "description": "Identifier of the node to highlight." }, + { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "optional": true, "description": "JavaScript object id of the node to be highlighted." }, { "name": "highlightConfig", "$ref": "HighlightConfig", "description": "A descriptor for the highlight appearance." } ], - "description": "Highlights DOM node with given id." + "description": "Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or objectId must be specified." }, { "name": "hideHighlight", diff --git a/Source/WebCore/inspector/InspectorDOMAgent.cpp b/Source/WebCore/inspector/InspectorDOMAgent.cpp index 1b0893472..9b8890ac6 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.cpp +++ b/Source/WebCore/inspector/InspectorDOMAgent.cpp @@ -1066,12 +1066,19 @@ void InspectorDOMAgent::highlightRect(ErrorString*, int x, int y, int width, int m_overlay->highlightRect(adoptPtr(new IntRect(x, y, width, height)), *highlightConfig); } -void InspectorDOMAgent::highlightNode( - ErrorString* errorString, - int nodeId, - const RefPtr<InspectorObject>& highlightInspectorObject) -{ - Node* node = nodeForId(nodeId); +void InspectorDOMAgent::highlightNode(ErrorString* errorString, const int* nodeId, const String* objectId, const RefPtr<InspectorObject>& highlightInspectorObject) +{ + Node* node = 0; + if (nodeId) { + node = assertNode(errorString, *nodeId); + } else if (objectId) { + InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*objectId); + node = injectedScript.nodeForObjectId(*objectId); + if (!node) + *errorString = "Node for given objectId not found"; + } else + *errorString = "Either nodeId or objectId must be specified"; + if (!node) return; diff --git a/Source/WebCore/inspector/InspectorDOMAgent.h b/Source/WebCore/inspector/InspectorDOMAgent.h index 3b7265283..f7cc5fb18 100644 --- a/Source/WebCore/inspector/InspectorDOMAgent.h +++ b/Source/WebCore/inspector/InspectorDOMAgent.h @@ -141,7 +141,7 @@ public: virtual void pushNodeByPathToFrontend(ErrorString*, const String& path, int* nodeId); virtual void hideHighlight(ErrorString*); virtual void highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor); - virtual void highlightNode(ErrorString*, int nodeId, const RefPtr<InspectorObject>& highlightConfig); + virtual void highlightNode(ErrorString*, const int* nodeId, const String* objectId, const RefPtr<InspectorObject>& highlightConfig); virtual void highlightFrame(ErrorString*, const String& frameId, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor); virtual void moveTo(ErrorString*, int nodeId, int targetNodeId, const int* anchorNodeId, int* newNodeId); virtual void undo(ErrorString*); diff --git a/Source/WebCore/inspector/front-end/ConsoleMessage.js b/Source/WebCore/inspector/front-end/ConsoleMessage.js index 39e4f6b9c..64f1ca17b 100644 --- a/Source/WebCore/inspector/front-end/ConsoleMessage.js +++ b/Source/WebCore/inspector/front-end/ConsoleMessage.js @@ -351,12 +351,7 @@ WebInspector.ConsoleMessageImpl.prototype = { if (property.type === "object" && property.subtype === "node") { span.addStyleClass("console-formatted-preview-node"); - var match = property.value.match(/([^#.]+)(#[^.]+)?(\..*)?/); - span.createChild("span", "webkit-html-tag-name").textContent = match[1]; - if (match[2]) - span.createChild("span", "webkit-html-attribute-value").textContent = match[2]; - if (match[3]) - span.createChild("span", "webkit-html-attribute-name").textContent = match[3]; + WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, property.value); return; } diff --git a/Source/WebCore/inspector/front-end/DOMAgent.js b/Source/WebCore/inspector/front-end/DOMAgent.js index ef4869383..afbbd7655 100644 --- a/Source/WebCore/inspector/front-end/DOMAgent.js +++ b/Source/WebCore/inspector/front-end/DOMAgent.js @@ -1198,17 +1198,17 @@ WebInspector.DOMAgent.prototype = { /** * @param {?number} nodeId * @param {string=} mode + * @param {RuntimeAgent.RemoteObjectId=} objectId */ - highlightDOMNode: function(nodeId, mode) + highlightDOMNode: function(nodeId, mode, objectId) { if (this._hideDOMNodeHighlightTimeout) { clearTimeout(this._hideDOMNodeHighlightTimeout); delete this._hideDOMNodeHighlightTimeout; } - this._highlightedDOMNodeId = nodeId; - if (nodeId) - DOMAgent.highlightNode(nodeId, this._buildHighlightConfig(mode)); + if (objectId || nodeId) + DOMAgent.highlightNode(objectId ? undefined : nodeId, objectId, this._buildHighlightConfig(mode)); else DOMAgent.hideHighlight(); }, diff --git a/Source/WebCore/inspector/front-end/DOMExtension.js b/Source/WebCore/inspector/front-end/DOMExtension.js index 162fa964d..5bfcd2233 100644 --- a/Source/WebCore/inspector/front-end/DOMExtension.js +++ b/Source/WebCore/inspector/front-end/DOMExtension.js @@ -195,6 +195,18 @@ Element.prototype.remove = function() this.parentElement.removeChild(this); } +/** + * @param {Node} fromNode + * @param {Node} toNode + */ +function removeSubsequentNodes(fromNode, toNode) +{ + for (var node = fromNode; node && node !== toNode; ) { + var nodeToRemove = node; + node = node.nextSibling; + nodeToRemove.remove(); + } +} /** * @constructor diff --git a/Source/WebCore/inspector/front-end/DOMPresentationUtils.js b/Source/WebCore/inspector/front-end/DOMPresentationUtils.js index 905b78f9f..d70569dbe 100644 --- a/Source/WebCore/inspector/front-end/DOMPresentationUtils.js +++ b/Source/WebCore/inspector/front-end/DOMPresentationUtils.js @@ -76,6 +76,20 @@ WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme parentElement.title = title; } +/** + * @param {Element} container + * @param {string} nodeTitle + */ +WebInspector.DOMPresentationUtils.createSpansForNodeTitle = function(container, nodeTitle) +{ + var match = nodeTitle.match(/([^#.]+)(#[^.]+)?(\..*)?/); + container.createChild("span", "webkit-html-tag-name").textContent = match[1]; + if (match[2]) + container.createChild("span", "webkit-html-attribute-value").textContent = match[2]; + if (match[3]) + container.createChild("span", "webkit-html-attribute-name").textContent = match[3]; +} + WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node) { var link = document.createElement("span"); diff --git a/Source/WebCore/inspector/front-end/DefaultTextEditor.js b/Source/WebCore/inspector/front-end/DefaultTextEditor.js index 08f48e08f..458e54552 100644 --- a/Source/WebCore/inspector/front-end/DefaultTextEditor.js +++ b/Source/WebCore/inspector/front-end/DefaultTextEditor.js @@ -2415,13 +2415,28 @@ WebInspector.TextEditorMainPanel.prototype = { // Remove damaged chunks from DOM and from textChunks model. var lastUndamagedChunk = firstDamagedChunkNumber > 0 ? this._textChunks[firstDamagedChunkNumber - 1] : null; var firstUndamagedChunk = lastDamagedChunkNumber + 1 < this._textChunks.length ? this._textChunks[lastDamagedChunkNumber + 1] : null; + var removeDOMFromNode = lastUndamagedChunk ? lastUndamagedChunk.lastElement().nextSibling : this._container.firstChild; var removeDOMToNode = firstUndamagedChunk ? firstUndamagedChunk.firstElement() : null; - for (var node = removeDOMFromNode; node && node !== removeDOMToNode; ) { - var nodeToRemove = node; - node = node.nextSibling; - nodeToRemove.remove(); + + // Fast case - patch single expanded chunk that did not grow / shrink during edit. + if (!linesDiff && firstDamagedChunk === lastDamagedChunk && firstDamagedChunk._expandedLineRows) { + var lastUndamagedLineRow = lastDamagedChunk.expandedLineRow(oldRange.startLine - 1); + var firstUndamagedLineRow = firstDamagedChunk.expandedLineRow(oldRange.endLine + 1); + var localRemoveDOMFromNode = lastUndamagedLineRow ? lastUndamagedLineRow.nextSibling : removeDOMFromNode; + var localRemoveDOMToNode = firstUndamagedLineRow || removeDOMToNode; + removeSubsequentNodes(localRemoveDOMFromNode, localRemoveDOMToNode); + for (var i = newRange.startLine; i < newRange.endLine + 1; ++i) { + var row = firstDamagedChunk._createRow(i); + firstDamagedChunk._expandedLineRows[i - firstDamagedChunk.startLine] = row; + this._container.insertBefore(row, localRemoveDOMToNode); + } + firstDamagedChunk.updateCollapsedLineRow(); + this._assertDOMMatchesTextModel(); + return; } + + removeSubsequentNodes(removeDOMFromNode, removeDOMToNode); this._textChunks.splice(firstDamagedChunkNumber, lastDamagedChunkNumber - firstDamagedChunkNumber + 1); // Compute damaged chunks span diff --git a/Source/WebCore/inspector/front-end/MemoryStatistics.js b/Source/WebCore/inspector/front-end/MemoryStatistics.js index d44cc65d0..aa83b1f01 100644 --- a/Source/WebCore/inspector/front-end/MemoryStatistics.js +++ b/Source/WebCore/inspector/front-end/MemoryStatistics.js @@ -314,10 +314,11 @@ WebInspector.MemoryStatistics.prototype = { _onClick: function(event) { - var x = event.x - event.target.offsetParent.offsetLeft + var x = event.x - event.target.offsetParent.offsetLeft; var i = this._recordIndexAt(x); var counter = this._counters[i]; - this._timelinePanel.revealRecordAt(counter.time / 1000); + if (counter) + this._timelinePanel.revealRecordAt(counter.time / 1000); }, _onMouseOut: function(event) diff --git a/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js b/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js index a9d046c3f..d43099c97 100644 --- a/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js +++ b/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js @@ -55,22 +55,49 @@ WebInspector.NativeMemorySnapshotView.prototype = { WebInspector.NativeSnapshotDataGrid = function(profile) { var columns = { - object: { title: WebInspector.UIString("Object"), width: "200px", disclosure: true, sortable: false }, - size: { title: WebInspector.UIString("Size"), sortable: false }, + name: { title: WebInspector.UIString("Object"), width: "200px", disclosure: true, sortable: true }, + size: { title: WebInspector.UIString("Size"), sortable: true, sort: "descending" }, }; WebInspector.DataGrid.call(this, columns); - var totalNode = new WebInspector.NativeSnapshotNode(profile, profile); + this._totalNode = new WebInspector.NativeSnapshotNode(profile, profile); if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get()) { this.setRootNode(new WebInspector.DataGridNode(null, true)); - this.rootNode().appendChild(totalNode) - totalNode.expand(); + this.rootNode().appendChild(this._totalNode) + this._totalNode.expand(); } else { - this.setRootNode(totalNode); - totalNode._populate(); + this.setRootNode(this._totalNode); + this._totalNode._populate(); } + this.addEventListener("sorting changed", this.sortingChanged.bind(this), this); } WebInspector.NativeSnapshotDataGrid.prototype = { + sortingChanged: function() + { + var expandedNodes = {}; + this._totalNode._storeState(expandedNodes); + this._totalNode.removeChildren(); + this._totalNode._populate(); + this._totalNode._shouldRefreshChildren = true; + this._totalNode._restoreState(expandedNodes); + }, + + /** + * @param {MemoryAgent.MemoryBlock} nodeA + * @param {MemoryAgent.MemoryBlock} nodeB + */ + _sortingFunction: function(nodeA, nodeB) + { + var sortColumnIdentifier = this.sortColumnIdentifier; + var sortAscending = this.sortOrder === "ascending"; + var field1 = nodeA[sortColumnIdentifier]; + var field2 = nodeB[sortColumnIdentifier]; + var result = field1 < field2 ? -1 : (field1 > field2 ? 1 : 0); + if (!sortAscending) + result = -result; + return result; + }, + __proto__: WebInspector.DataGrid.prototype } @@ -85,7 +112,7 @@ WebInspector.NativeSnapshotNode = function(nodeData, profile) this._nodeData = nodeData; this._profile = profile; var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(nodeData); - var data = { object: viewProperties._description, size: this._nodeData.size }; + var data = { name: viewProperties._description, size: this._nodeData.size }; var hasChildren = !!nodeData.children && nodeData.children.length !== 0; WebInspector.DataGridNode.call(this, data, hasChildren); this.addEventListener("populate", this._populate, this); @@ -106,6 +133,40 @@ WebInspector.NativeSnapshotNode.prototype = { }, /** + * @param {Object} expandedNodes + */ + _storeState: function(expandedNodes) + { + if (!this.expanded) + return; + expandedNodes[this.uid()] = true; + for (var i in this.children) + this.children[i]._storeState(expandedNodes); + }, + + /** + * @param {Object} expandedNodes + */ + _restoreState: function(expandedNodes) + { + if (!expandedNodes[this.uid()]) + return; + this.expand(); + for (var i in this.children) + this.children[i]._restoreState(expandedNodes); + }, + + /** + * @return {string} + */ + uid: function() + { + if (!this._uid) + this._uid = (!this.parent || !this.parent.uid ? "" : this.parent.uid() || "") + "/" + this._nodeData.name; + return this._uid; + }, + + /** * @param {string} columnIdentifier * @return {Element} */ @@ -121,7 +182,7 @@ WebInspector.NativeSnapshotNode.prototype = { node = node.parent; } - var sizeKiB = this._nodeData.size / 1024; + var sizeKB = this._nodeData.size / 1024; var totalSize = this._profile.size; var percentage = this._nodeData.size / totalSize * 100; @@ -129,7 +190,7 @@ WebInspector.NativeSnapshotNode.prototype = { cell.className = columnIdentifier + "-column"; var textDiv = document.createElement("div"); - textDiv.textContent = Number.withThousandsSeparator(sizeKiB.toFixed(0)) + "\u2009" + WebInspector.UIString("KiB"); + textDiv.textContent = Number.withThousandsSeparator(sizeKB.toFixed(0)) + "\u2009" + WebInspector.UIString("KB"); textDiv.className = "size-text"; cell.appendChild(textDiv); @@ -157,11 +218,7 @@ WebInspector.NativeSnapshotNode.prototype = { _populate: function() { this.removeEventListener("populate", this._populate, this); - function comparator(a, b) { - return b.size - a.size; - } - if (this._nodeData !== this._profile) - this._nodeData.children.sort(comparator); + this._nodeData.children.sort(this.dataGrid._sortingFunction.bind(this.dataGrid)); for (var node in this._nodeData.children) { var nodeData = this._nodeData.children[node]; if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get() || nodeData.name !== "Other") diff --git a/Source/WebCore/inspector/front-end/NavigatorView.js b/Source/WebCore/inspector/front-end/NavigatorView.js index c9103bba2..b740bbf68 100644 --- a/Source/WebCore/inspector/front-end/NavigatorView.js +++ b/Source/WebCore/inspector/front-end/NavigatorView.js @@ -479,6 +479,8 @@ WebInspector.BaseNavigatorTreeElement.prototype = { set titleText(titleText) { + if (this._titleText === titleText) + return; this._titleText = titleText || ""; if (this.titleElement) this.titleElement.textContent = this._titleText; diff --git a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js index bcbf01386..e4be780f9 100644 --- a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js +++ b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js @@ -234,7 +234,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = { } else if (this.property.value.type === "function" && typeof description === "string") { this.valueElement.textContent = /.*/.exec(description)[0].replace(/ +$/g, ""); this.valueElement._originalTextContent = description; - } else + } else if (this.property.value.type !== "object" || this.property.value.subtype !== "node") this.valueElement.textContent = description; if (this.property.wasThrown) @@ -245,7 +245,12 @@ WebInspector.ObjectPropertyTreeElement.prototype = { this.valueElement.addStyleClass("console-formatted-" + this.property.value.type); this.valueElement.addEventListener("contextmenu", this._contextMenuFired.bind(this, this.property.value), false); - this.valueElement.title = description || ""; + if (this.property.value.type === "object" && this.property.value.subtype === "node") { + WebInspector.DOMPresentationUtils.createSpansForNodeTitle(this.valueElement, this.property.value.description); + this.valueElement.addEventListener("mousemove", this._mouseMove.bind(this, this.property.value), false); + this.valueElement.addEventListener("mouseout", this._mouseOut.bind(this, this.property.value), false); + } else + this.valueElement.title = description || ""; this.listItemElement.removeChildren(); @@ -270,6 +275,16 @@ WebInspector.ObjectPropertyTreeElement.prototype = { { }, + _mouseMove: function(event) + { + this.property.value.highlightAsDOMNode(); + }, + + _mouseOut: function(event) + { + this.property.value.hideDOMNodeHighlight(); + }, + updateSiblings: function() { if (this.parent.root) diff --git a/Source/WebCore/inspector/front-end/RemoteObject.js b/Source/WebCore/inspector/front-end/RemoteObject.js index 3f080b352..35cbf1b6b 100644 --- a/Source/WebCore/inspector/front-end/RemoteObject.js +++ b/Source/WebCore/inspector/front-end/RemoteObject.js @@ -288,6 +288,16 @@ WebInspector.RemoteObject.prototype = { callback(0); }, + highlightAsDOMNode: function() + { + WebInspector.domAgent.highlightDOMNode(undefined, undefined, this._objectId); + }, + + hideDOMNodeHighlight: function() + { + WebInspector.domAgent.hideDOMNodeHighlight(); + }, + /** * @param {function(this:Object)} functionDeclaration * @param {Array.<RuntimeAgent.CallArgument>=} args diff --git a/Source/WebCore/inspector/front-end/TabbedPane.js b/Source/WebCore/inspector/front-end/TabbedPane.js index 18ba6186d..817b0539e 100644 --- a/Source/WebCore/inspector/front-end/TabbedPane.js +++ b/Source/WebCore/inspector/front-end/TabbedPane.js @@ -598,6 +598,8 @@ WebInspector.TabbedPaneTab.prototype = { set title(title) { + if (title === this._title) + return; this._title = title; if (this._titleElement) this._titleElement.textContent = title; diff --git a/Source/WebCore/inspector/front-end/TestController.js b/Source/WebCore/inspector/front-end/TestController.js index b46026199..bb400ed32 100644 --- a/Source/WebCore/inspector/front-end/TestController.js +++ b/Source/WebCore/inspector/front-end/TestController.js @@ -45,7 +45,7 @@ WebInspector.TestController.prototype = { WebInspector.evaluateForTestInFrontend = function(callId, script) { - WebInspector.isUnderTest = true; + window.isUnderTest = true; function invokeMethod() { try { diff --git a/Source/WebCore/inspector/front-end/externs.js b/Source/WebCore/inspector/front-end/externs.js index be792be6d..8c5a4ef8a 100644 --- a/Source/WebCore/inspector/front-end/externs.js +++ b/Source/WebCore/inspector/front-end/externs.js @@ -65,6 +65,8 @@ function postMessage(message) {} /** @type {*} */ window.testRunner = null; +window.isUnderTest = false; + /** * @constructor */ diff --git a/Source/WebCore/inspector/front-end/inspector.css b/Source/WebCore/inspector/front-end/inspector.css index 54bb4695b..d0fab33ba 100644 --- a/Source/WebCore/inspector/front-end/inspector.css +++ b/Source/WebCore/inspector/front-end/inspector.css @@ -1141,6 +1141,10 @@ ol.watch-expressions > li.hovered { color: black; } +.console-formatted-node:hover { + background-color: rgba(56, 121, 217, 0.1); +} + .console-formatted-object .section, .console-formatted-node .section, .console-formatted-array .section { position: static; } diff --git a/Source/WebCore/inspector/front-end/utilities.js b/Source/WebCore/inspector/front-end/utilities.js index 043e886e9..b4bbec510 100644 --- a/Source/WebCore/inspector/front-end/utilities.js +++ b/Source/WebCore/inspector/front-end/utilities.js @@ -861,6 +861,7 @@ function importScript(scriptName) window.eval(xhr.responseText + "\n//@ sourceURL=" + scriptName); } +window.isUnderTest = false; /** * Mutation observers leak memory. Keep track of them and disconnect @@ -872,7 +873,7 @@ function NonLeakingMutationObserver(handler) { this._observer = new WebKitMutationObserver(handler); NonLeakingMutationObserver._instances.push(this); - if (!window.testRunner && !WebInspector.isUnderTest && !NonLeakingMutationObserver._unloadListener) { + if (!window.testRunner && !window.isUnderTest && !NonLeakingMutationObserver._unloadListener) { NonLeakingMutationObserver._unloadListener = function() { while (NonLeakingMutationObserver._instances.length) NonLeakingMutationObserver._instances[NonLeakingMutationObserver._instances.length - 1].disconnect(); |