This source file includes following definitions.
- m_inspectorDOMAgent
- clearMessages
- get
- addInspectedNode
#include "config.h"
#include "core/inspector/PageConsoleAgent.h"
#include "core/dom/Node.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/inspector/InjectedScriptHost.h"
#include "core/inspector/InjectedScriptManager.h"
#include "core/inspector/InspectorDOMAgent.h"
namespace WebCore {
PageConsoleAgent::PageConsoleAgent(InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent, InspectorTimelineAgent* timelineAgent)
: InspectorConsoleAgent(timelineAgent, injectedScriptManager)
, m_inspectorDOMAgent(domAgent)
{
}
PageConsoleAgent::~PageConsoleAgent()
{
m_inspectorDOMAgent = 0;
}
void PageConsoleAgent::clearMessages(ErrorString* errorString)
{
m_inspectorDOMAgent->releaseDanglingNodes();
InspectorConsoleAgent::clearMessages(errorString);
}
class InspectableNode FINAL : public InjectedScriptHost::InspectableObject {
public:
explicit InspectableNode(Node* node) : m_node(node) { }
virtual ScriptValue get(ScriptState* state) OVERRIDE
{
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) {
*errorString = "nodeId is not valid";
return;
}
while (node->isInShadowTree()) {
Node& ancestor = node->highestAncestor();
if (!ancestor.isShadowRoot() || toShadowRoot(ancestor).type() == ShadowRoot::AuthorShadowRoot)
break;
node = toShadowRoot(ancestor).host();
}
m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableNode(node)));
}
}