Diff
Modified: trunk/Source/WebCore/ChangeLog (136143 => 136144)
--- trunk/Source/WebCore/ChangeLog 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/ChangeLog 2012-11-29 19:59:14 UTC (rev 136144)
@@ -1,3 +1,37 @@
+2012-11-29 Pavel Feldman <[email protected]>
+
+ Web Inspector: Console: hovering node wrappers in object tree should highlight them on the page
+ https://bugs.webkit.org/show_bug.cgi?id=101150
+
+ Reviewed by Vsevolod Vlasov.
+
+ - Introduced a way to highlight nodes by object id in addition to node id.
+ - Decorated nodes in the object tree outline and added on-hover highlighting.
+
+ * inspector/Inspector.json:
+ * inspector/InspectorDOMAgent.cpp:
+ (WebCore::InspectorDOMAgent::highlightNode):
+ * inspector/InspectorDOMAgent.h:
+ (InspectorDOMAgent):
+ * inspector/front-end/ConsoleMessage.js:
+ (WebInspector.ConsoleMessageImpl.prototype._appendPropertyPreview):
+ * inspector/front-end/DOMAgent.js:
+ (WebInspector.DOMAgent.prototype.highlightDOMNode):
+ * inspector/front-end/DOMPresentationUtils.js:
+ (WebInspector.DOMPresentationUtils.createSpansForNodeTitle):
+ * inspector/front-end/ObjectPropertiesSection.js:
+ (WebInspector.ObjectPropertyTreeElement.prototype.update):
+ (WebInspector.ObjectPropertyTreeElement.prototype._mouseMove):
+ (WebInspector.ObjectPropertyTreeElement.prototype._mouseOut):
+ * inspector/front-end/RemoteObject.js:
+ (WebInspector.RemoteObject.prototype.highlightAsDOMNode):
+ (WebInspector.RemoteObject.prototype.hideDOMNodeHighlight):
+ * inspector/front-end/TestController.js:
+ * inspector/front-end/externs.js:
+ * inspector/front-end/inspector.css:
+ (.console-formatted-node:hover):
+ * inspector/front-end/utilities.js:
+
2012-11-29 Dan Bernstein <[email protected]>
<rdar://problem/12771885> Support ruby-position: {before, after}
Modified: trunk/Source/WebCore/inspector/Inspector.json (136143 => 136144)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-11-29 19:59:14 UTC (rev 136144)
@@ -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",
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (136143 => 136144)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-11-29 19:59:14 UTC (rev 136144)
@@ -1066,12 +1066,19 @@
m_overlay->highlightRect(adoptPtr(new IntRect(x, y, width, height)), *highlightConfig);
}
-void InspectorDOMAgent::highlightNode(
- ErrorString* errorString,
- int nodeId,
- const RefPtr<InspectorObject>& highlightInspectorObject)
+void InspectorDOMAgent::highlightNode(ErrorString* errorString, const int* nodeId, const String* objectId, const RefPtr<InspectorObject>& highlightInspectorObject)
{
- Node* node = nodeForId(nodeId);
+ 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;
Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (136143 => 136144)
--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h 2012-11-29 19:59:14 UTC (rev 136144)
@@ -141,7 +141,7 @@
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*);
Modified: trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -351,12 +351,7 @@
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;
}
Modified: trunk/Source/WebCore/inspector/front-end/DOMAgent.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/DOMAgent.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/DOMAgent.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -1198,17 +1198,17 @@
/**
* @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();
},
Modified: trunk/Source/WebCore/inspector/front-end/DOMPresentationUtils.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/DOMPresentationUtils.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/DOMPresentationUtils.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -76,6 +76,20 @@
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");
Modified: trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -234,7 +234,7 @@
} 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 @@
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 @@
{
},
+ _mouseMove: function(event)
+ {
+ this.property.value.highlightAsDOMNode();
+ },
+
+ _mouseOut: function(event)
+ {
+ this.property.value.hideDOMNodeHighlight();
+ },
+
updateSiblings: function()
{
if (this.parent.root)
Modified: trunk/Source/WebCore/inspector/front-end/RemoteObject.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/RemoteObject.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/RemoteObject.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -288,6 +288,16 @@
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
Modified: trunk/Source/WebCore/inspector/front-end/TestController.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/TestController.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/TestController.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -45,7 +45,7 @@
WebInspector.evaluateForTestInFrontend = function(callId, script)
{
- WebInspector.isUnderTest = true;
+ window.isUnderTest = true;
function invokeMethod()
{
try {
Modified: trunk/Source/WebCore/inspector/front-end/externs.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/externs.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/externs.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -65,6 +65,8 @@
/** @type {*} */
window.testRunner = null;
+window.isUnderTest = false;
+
/**
* @constructor
*/
Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/inspector.css 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css 2012-11-29 19:59:14 UTC (rev 136144)
@@ -1141,6 +1141,10 @@
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;
}
Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (136143 => 136144)
--- trunk/Source/WebCore/inspector/front-end/utilities.js 2012-11-29 19:28:14 UTC (rev 136143)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js 2012-11-29 19:59:14 UTC (rev 136144)
@@ -861,6 +861,7 @@
window.eval(xhr.responseText + "\n//@ sourceURL=" + scriptName);
}
+window.isUnderTest = false;
/**
* Mutation observers leak memory. Keep track of them and disconnect
@@ -872,7 +873,7 @@
{
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();