https://bugs.webkit.org/show_bug.cgi?id=78496
Reviewed by Yury Semikhatsky.
Source/WebCore:
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::JSInjectedScriptHost::inspectedObject):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::V8InjectedScriptHost::inspectedObjectCallback):
* inspector/InjectedScriptHost.cpp:
(WebCore::InjectedScriptHost::InjectedScriptHost):
(WebCore::InjectedScriptHost::InspectableObject::get):
(WebCore):
(WebCore::InjectedScriptHost::addInspectedObject):
(WebCore::InjectedScriptHost::clearInspectedObjects):
(WebCore::InjectedScriptHost::inspectedObject):
* inspector/InjectedScriptHost.h:
(InspectableObject):
(WebCore::InjectedScriptHost::InspectableObject::~InspectableObject):
(InjectedScriptHost):
* inspector/InjectedScriptHost.idl:
* inspector/InjectedScriptSource.js:
(.):
* inspector/Inspector.json:
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::domContentLoadedEventFired):
* inspector/InspectorConsoleAgent.cpp:
(InspectableHeapObject):
(WebCore::InspectableHeapObject::InspectableHeapObject):
(WebCore::InspectableHeapObject::get):
(WebCore):
(WebCore::InspectorConsoleAgent::addInspectedHeapObject):
* inspector/InspectorConsoleAgent.h:
(InspectorConsoleAgent):
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::resetState):
* inspector/PageConsoleAgent.cpp:
(InspectableNode):
(WebCore::InspectableNode::InspectableNode):
(WebCore::InspectableNode::get):
(WebCore):
(WebCore::PageConsoleAgent::addInspectedNode):
* inspector/front-end/DetailedHeapshotView.js:
(WebInspector.DetailedHeapshotView.prototype._selectionChanged):
(WebInspector.DetailedHeapshotView.prototype._inspectedObjectChanged):
LayoutTests:
* inspector/protocol/console-agent-expected.txt:
* inspector/protocol/console-agent.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107929
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2012-02-16 Ilya Tikhonovsky <loislo@chromium.org>
+ Web Inspector: [heap snapshot] It could be useful to have access to the selected heap object from the console.
+ https://bugs.webkit.org/show_bug.cgi?id=78496
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/protocol/console-agent-expected.txt:
+ * inspector/protocol/console-agent.html:
+
+2012-02-16 Ilya Tikhonovsky <loislo@chromium.org>
+
[chromium] Rebaseline after r107881
* platform/chromium-mac-snowleopard/fast/css/getComputedStyle/computed-style-expected.txt: Added.
id : <number>
}
+-----------------------------------------------------------
+ConsoleAgent.addInspectedHeapObject(<number>)
+
+request:
+{
+ method : "Console.addInspectedHeapObject"
+ params : {
+ heapObjectId : 1
+ }
+ id : <number>
+}
+
+response:
+{
+ result : {
+ }
+ id : <number>
+}
+
===========================================================
Coverage for ConsoleAgent
{
clearMessages : "checked"
setMonitoringXHREnabled : "checked"
addInspectedNode : "checked"
+ addInspectedHeapObject : "checked"
messageAdded : "checked"
messageRepeatCountUpdated : "checked"
messagesCleared : "checked"
["ConsoleAgent", "clearMessages"],
["ConsoleAgent", "setMonitoringXHREnabled", true],
["ConsoleAgent", "setMonitoringXHREnabled", false],
- ["ConsoleAgent", "addInspectedNode", 1]
+ ["ConsoleAgent", "addInspectedNode", 1],
+ ["ConsoleAgent", "addInspectedHeapObject", 1]
];
InspectorTest.runProtocolTestSuite("ConsoleAgent", testSuite, ['id', 'requestId', 'injectedScriptId', 'stackTrace']);
+2012-02-16 Ilya Tikhonovsky <loislo@chromium.org>
+
+ Web Inspector: [heap snapshot] It could be useful to have access to the selected heap object from the console.
+ https://bugs.webkit.org/show_bug.cgi?id=78496
+
+ Reviewed by Yury Semikhatsky.
+
+ * bindings/js/JSInjectedScriptHostCustom.cpp:
+ (WebCore::JSInjectedScriptHost::inspectedObject):
+ * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+ (WebCore::V8InjectedScriptHost::inspectedObjectCallback):
+ * inspector/InjectedScriptHost.cpp:
+ (WebCore::InjectedScriptHost::InjectedScriptHost):
+ (WebCore::InjectedScriptHost::InspectableObject::get):
+ (WebCore):
+ (WebCore::InjectedScriptHost::addInspectedObject):
+ (WebCore::InjectedScriptHost::clearInspectedObjects):
+ (WebCore::InjectedScriptHost::inspectedObject):
+ * inspector/InjectedScriptHost.h:
+ (InspectableObject):
+ (WebCore::InjectedScriptHost::InspectableObject::~InspectableObject):
+ (InjectedScriptHost):
+ * inspector/InjectedScriptHost.idl:
+ * inspector/InjectedScriptSource.js:
+ (.):
+ * inspector/Inspector.json:
+ * inspector/InspectorAgent.cpp:
+ (WebCore::InspectorAgent::domContentLoadedEventFired):
+ * inspector/InspectorConsoleAgent.cpp:
+ (InspectableHeapObject):
+ (WebCore::InspectableHeapObject::InspectableHeapObject):
+ (WebCore::InspectableHeapObject::get):
+ (WebCore):
+ (WebCore::InspectorConsoleAgent::addInspectedHeapObject):
+ * inspector/InspectorConsoleAgent.h:
+ (InspectorConsoleAgent):
+ * inspector/InspectorProfilerAgent.cpp:
+ (WebCore::InspectorProfilerAgent::resetState):
+ * inspector/PageConsoleAgent.cpp:
+ (InspectableNode):
+ (WebCore::InspectableNode::InspectableNode):
+ (WebCore::InspectableNode::get):
+ (WebCore):
+ (WebCore::PageConsoleAgent::addInspectedNode):
+ * inspector/front-end/DetailedHeapshotView.js:
+ (WebInspector.DetailedHeapshotView.prototype._selectionChanged):
+ (WebInspector.DetailedHeapshotView.prototype._inspectedObjectChanged):
+
2012-02-16 Kihong Kwon <kihong.kwon@samsung.com>
Add support for unsigned long[] to idl bindings to JSC.
return ScriptValue(state->globalData(), toJS(state, deprecatedGlobalObjectForPrototype(state), node));
}
-JSValue JSInjectedScriptHost::inspectedNode(ExecState* exec)
+JSValue JSInjectedScriptHost::inspectedObject(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
- Node* node = impl()->inspectedNode(exec->argument(0).toInt32(exec));
- if (!node)
+ InjectedScriptHost::InspectableObject* object = impl()->inspectedObject(exec->argument(0).toInt32(exec));
+ if (!object)
return jsUndefined();
JSLock lock(SilenceAssertionsOnly);
- return toJS(exec, globalObject(), node);
+ return object->get(exec).jsValue();
}
JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec)
return ScriptValue(toV8(node));
}
-v8::Handle<v8::Value> V8InjectedScriptHost::inspectedNodeCallback(const v8::Arguments& args)
+v8::Handle<v8::Value> V8InjectedScriptHost::inspectedObjectCallback(const v8::Arguments& args)
{
- INC_STATS("InjectedScriptHost.inspectedNode()");
+ INC_STATS("InjectedScriptHost.inspectedObject()");
if (args.Length() < 1)
return v8::Undefined();
- InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
-
- Node* node = host->inspectedNode(args[0]->ToInt32()->Value());
- if (!node)
+ if (!args[0]->IsInt32()) {
+ throwError("argument has to be an integer");
return v8::Undefined();
+ }
- return toV8(node);
+ InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
+ InjectedScriptHost::InspectableObject* object = host->inspectedObject(args[0]->ToInt32()->Value());
+ return object->get(ScriptState::current()).v8Value();
}
v8::Handle<v8::Value> V8InjectedScriptHost::internalConstructorNameCallback(const v8::Arguments& args)
, m_domStorageAgent(0)
, m_lastWorkerId(1 << 31) // Distinguish ids of fake workers from real ones, to minimize the chances they overlap.
{
+ m_defaultInspectableObject = adoptPtr(new InspectableObject());
}
InjectedScriptHost::~InjectedScriptHost()
m_domStorageAgent = 0;
}
-void InjectedScriptHost::addInspectedNode(Node* node)
-{
- m_inspectedNodes.prepend(node);
- while (m_inspectedNodes.size() > 5)
- m_inspectedNodes.removeLast();
-}
-
-void InjectedScriptHost::clearInspectedNodes()
-{
- m_inspectedNodes.clear();
-}
-
void InjectedScriptHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints)
{
if (m_inspectorAgent)
Pasteboard::generalPasteboard()->writePlainText(text);
}
-Node* InjectedScriptHost::inspectedNode(unsigned int num)
+ScriptValue InjectedScriptHost::InspectableObject::get(ScriptState*)
{
- if (num < m_inspectedNodes.size())
- return m_inspectedNodes[num].get();
- return 0;
+ return ScriptValue();
+};
+
+void InjectedScriptHost::addInspectedObject(PassOwnPtr<InjectedScriptHost::InspectableObject> object)
+{
+ m_inspectedObjects.prepend(object);
+ while (m_inspectedObjects.size() > 5)
+ m_inspectedObjects.removeLast();
+}
+
+void InjectedScriptHost::clearInspectedObjects()
+{
+ m_inspectedObjects.clear();
+}
+
+InjectedScriptHost::InspectableObject* InjectedScriptHost::inspectedObject(unsigned int num)
+{
+ if (num >= m_inspectedObjects.size())
+ return m_defaultInspectableObject.get();
+ return m_inspectedObjects[num].get();
}
#if ENABLE(SQL_DATABASE)
void disconnect();
- void addInspectedNode(Node*);
- void clearInspectedNodes();
+ class InspectableObject {
+ public:
+ virtual ScriptValue get(ScriptState*);
+ virtual ~InspectableObject() { }
+ };
+ void addInspectedObject(PassOwnPtr<InspectableObject>);
+ void clearInspectedObjects();
+ InspectableObject* inspectedObject(unsigned int num);
void inspectImpl(PassRefPtr<InspectorValue> objectToInspect, PassRefPtr<InspectorValue> hints);
void clearConsoleMessages();
void copyText(const String& text);
- Node* inspectedNode(unsigned int num);
#if ENABLE(SQL_DATABASE)
int databaseIdImpl(Database*);
#endif
#endif
InspectorDOMStorageAgent* m_domStorageAgent;
long m_lastWorkerId;
- Vector<RefPtr<Node> > m_inspectedNodes;
+ Vector<OwnPtr<InspectableObject> > m_inspectedObjects;
+ OwnPtr<InspectableObject> m_defaultInspectableObject;
};
} // namespace WebCore
void copyText(in DOMString text);
[Custom] void inspect(in DOMObject objectId, in DOMObject hints);
- [Custom] DOMObject inspectedNode(in int num);
+ [Custom] DOMObject inspectedObject(in int num);
[Custom] DOMObject internalConstructorName(in DOMObject object);
[Custom] boolean isHTMLAllCollection(in DOMObject object);
[Custom] DOMString type(in DOMObject object);
if (member in inspectedWindow || inScopeVariables(member))
continue;
- this.__defineGetter__("$" + i, bind(commandLineAPIImpl, commandLineAPIImpl._inspectedNode, i));
+ this.__defineGetter__("$" + i, bind(commandLineAPIImpl, commandLineAPIImpl._inspectedObject, i));
}
}
InjectedScriptHost.clearConsoleMessages();
},
- _inspectedNode: function(num)
+ _inspectedObject: function(num)
{
- return InjectedScriptHost.inspectedNode(num);
+ return InjectedScriptHost.inspectedObject(num);
},
_normalizeEventTypes: function(types)
],
"description": "Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).",
"hidden": true
+ },
+ {
+ "name": "addInspectedHeapObject",
+ "parameters": [
+ { "name": "heapObjectId", "type": "integer" }
+ ]
}
],
"events": [
void InspectorAgent::domContentLoadedEventFired()
{
- m_injectedScriptManager->injectedScriptHost()->clearInspectedNodes();
+ m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
}
bool InspectorAgent::isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl)
#include "ScriptArguments.h"
#include "ScriptCallFrame.h"
#include "ScriptCallStack.h"
+#include "ScriptObject.h"
+#include "ScriptProfiler.h"
#include <wtf/CurrentTime.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
}
}
+class InspectableHeapObject : public InjectedScriptHost::InspectableObject {
+public:
+ explicit InspectableHeapObject(int heapObjectId) : m_heapObjectId(heapObjectId) { }
+ virtual ScriptValue get(ScriptState*)
+ {
+ return ScriptProfiler::objectByHeapObjectId(m_heapObjectId);
+ }
+private:
+ int m_heapObjectId;
+};
+
+void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHeapObjectId)
+{
+ m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableHeapObject(inspectedHeapObjectId)));
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
#endif
virtual void setMonitoringXHREnabled(ErrorString*, bool enabled);
virtual void addInspectedNode(ErrorString*, int nodeId) = 0;
+ virtual void addInspectedHeapObject(ErrorString*, int inspectedHeapObjectId);
protected:
void addConsoleMessage(PassOwnPtr<ConsoleMessage>);
#include "Console.h"
#include "InjectedScript.h"
+#include "InjectedScriptHost.h"
#include "InspectorConsoleAgent.h"
#include "InspectorFrontend.h"
#include "InspectorState.h"
m_nextUserInitiatedProfileNumber = 1;
m_nextUserInitiatedHeapSnapshotNumber = 1;
resetFrontendProfiles();
+ m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
}
void InspectorProfilerAgent::resetFrontendProfiles()
#include "InjectedScriptManager.h"
#include "InspectorAgent.h"
#include "InspectorDOMAgent.h"
+#include "Node.h"
+#include "ScriptObject.h"
namespace WebCore {
InspectorConsoleAgent::clearMessages(errorString);
}
-void PageConsoleAgent::addInspectedNode(ErrorString*, int nodeId)
+class InspectableNode : public InjectedScriptHost::InspectableObject {
+public:
+ explicit InspectableNode(Node* node) : m_node(node) { }
+ virtual ScriptValue get(ScriptState* state)
+ {
+ return InjectedScriptHost::nodeAsScriptValue(state, m_node);
+ }
+private:
+ Node* m_node;
+};
+
+void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId)
{
Node* node = m_inspectorDOMAgent->nodeForId(nodeId);
- if (!node)
+ if (!node) {
+ *errorString = "nodeId is not valid";
return;
- m_injectedScriptManager->injectedScriptHost()->addInspectedNode(node);
+ }
+ m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableNode(node)));
}
bool PageConsoleAgent::developerExtrasEnabled()
return m_inspectorAgent->developerExtrasEnabled();
}
-
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
this.retainmentDataGrid = new WebInspector.HeapSnapshotRetainmentDataGrid();
this.retainmentDataGrid.element.addEventListener("click", this._mouseClickInRetainmentGrid.bind(this), true);
this.retainmentDataGrid.show(this.retainmentView.element);
+ this.retainmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, this._inspectedObjectChanged, this);
this.retainmentView.show(this.element);
this.retainmentDataGrid.reset();
{
var selectedNode = event.target.selectedNode;
this._setRetainmentDataGridSource(selectedNode);
+ this._inspectedObjectChanged(event);
+ },
+
+ _inspectedObjectChanged: function(event)
+ {
+ var selectedNode = event.target.selectedNode;
+ ConsoleAgent.addInspectedObject(selectedNode.snapshotNodeId);
},
_setRetainmentDataGridSource: function(nodeItem)