2010-10-05 Pavel Podivilov <podivilov@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: extract Inspector Instrumentation API as a class
        https://bugs.webkit.org/show_bug.cgi?id=47173

        * bindings/js/JSXMLHttpRequestCustom.cpp:
        (WebCore::JSXMLHttpRequest::send):
        * bindings/js/ScriptController.cpp:
        (WebCore::ScriptController::evaluateInWorld):
        * bindings/v8/V8DOMWindowShell.cpp:
        * bindings/v8/V8Proxy.cpp:
        (WebCore::V8Proxy::evaluate):
        (WebCore::V8Proxy::callFunction):
        * bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
        (WebCore::V8XMLHttpRequest::sendCallback):
        * dom/Document.cpp:
        (WebCore::Document::recalcStyle):
        * dom/Document.h:
        * dom/Node.cpp:
        (WebCore::Node::dispatchGenericEvent):
        * html/parser/HTMLDocumentParser.cpp:
        (WebCore::HTMLDocumentParser::pumpTokenizer):
        * html/parser/HTMLDocumentParser.h:
        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::hasFrontend):
        (WebCore::InspectorInstrumentation::retrieveTimelineAgent):
        * inspector/InspectorInstrumentation.h:
        (WebCore::InspectorInstrumentation::hasFrontends):
        (WebCore::InspectorInstrumentation::inspectorControllerForContext):
        (WebCore::InspectorInstrumentation::inspectorControllerForDocument):
        (WebCore::InspectorInstrumentation::inspectorControllerForFrame):
        (WebCore::InspectorInstrumentation::inspectorControllerForPage):
        * inspector/InspectorTimelineAgent.cpp:
        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
        (WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
        * inspector/InspectorTimelineAgent.h:
        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::didReceiveResponse):
        (WebCore::ResourceLoader::didReceiveData):
        * loader/loader.cpp:
        (WebCore::Loader::load):
        * page/DOMTimer.cpp:
        (WebCore::DOMTimer::install):
        (WebCore::DOMTimer::removeById):
        (WebCore::DOMTimer::fired):
        * page/DOMTimer.h:
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::dispatchEvent):
        * page/DOMWindow.h:
        * page/FrameView.cpp:
        (WebCore::FrameView::layout):
        (WebCore::FrameView::paintContents):
        * page/FrameView.h:
        * page/Page.cpp:
        * page/Page.h:
        * rendering/RenderLayerBacking.cpp:
        (WebCore::RenderLayerBacking::paintContents):
        * xml/XMLHttpRequest.cpp:
        (WebCore::XMLHttpRequest::callReadyStateChangeListener):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69283 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ce662830
2010-10-05 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: extract Inspector Instrumentation API as a class
https://bugs.webkit.org/show_bug.cgi?id=47173
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::send):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/v8/V8DOMWindowShell.cpp:
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::evaluate):
(WebCore::V8Proxy::callFunction):
* bindings/v8/custom/V8XMLHttpRequestCustom.cpp:
(WebCore::V8XMLHttpRequest::sendCallback):
* dom/Document.cpp:
(WebCore::Document::recalcStyle):
* dom/Document.h:
* dom/Node.cpp:
(WebCore::Node::dispatchGenericEvent):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizer):
* html/parser/HTMLDocumentParser.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::hasFrontend):
(WebCore::InspectorInstrumentation::retrieveTimelineAgent):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::hasFrontends):
(WebCore::InspectorInstrumentation::inspectorControllerForContext):
(WebCore::InspectorInstrumentation::inspectorControllerForDocument):
(WebCore::InspectorInstrumentation::inspectorControllerForFrame):
(WebCore::InspectorInstrumentation::inspectorControllerForPage):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
* inspector/InspectorTimelineAgent.h:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::didReceiveResponse):
(WebCore::ResourceLoader::didReceiveData):
* loader/loader.cpp:
(WebCore::Loader::load):
* page/DOMTimer.cpp:
(WebCore::DOMTimer::install):
(WebCore::DOMTimer::removeById):
(WebCore::DOMTimer::fired):
* page/DOMTimer.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchEvent):
* page/DOMWindow.h:
* page/FrameView.cpp:
(WebCore::FrameView::layout):
(WebCore::FrameView::paintContents):
* page/FrameView.h:
* page/Page.cpp:
* page/Page.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintContents):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::callReadyStateChangeListener):
2010-10-07 Zraly Mike <mike.zraly@nokia.com>
Reviewed by Andreas Kling.
......@@ -94,7 +94,7 @@ JSValue JSXMLHttpRequest::open(ExecState* exec)
JSValue JSXMLHttpRequest::send(ExecState* exec)
{
InspectorInstrumentation::instrumentWillSendXMLHttpRequest(impl()->scriptExecutionContext(), impl()->url());
InspectorInstrumentation::willSendXMLHttpRequest(impl()->scriptExecutionContext(), impl()->url());
ExceptionCode ec = 0;
if (!exec->argumentCount())
......
......@@ -28,7 +28,7 @@
#include "FrameLoaderClient.h"
#include "GCController.h"
#include "HTMLPlugInElement.h"
#include "InspectorTimelineAgent.h"
#include "InspectorInstrumentation.h"
#include "JSDocument.h"
#include "JSMainThreadExecState.h"
#include "NP_jsobject.h"
......@@ -142,19 +142,13 @@ ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode
RefPtr<Frame> protect = m_frame;
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
timelineAgent->willEvaluateScript(sourceURL, sourceCode.startLine());
#endif
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, sourceURL, sourceCode.startLine());
exec->globalData().timeoutChecker.start();
Completion comp = JSMainThreadExecState::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell);
exec->globalData().timeoutChecker.stop();
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
timelineAgent->didEvaluateScript();
#endif
InspectorInstrumentation::didEvaluateScript(m_frame, cookie);
// Evaluating the JavaScript could cause the frame to be deallocated
// so we start the keep alive timer here.
......
......@@ -37,7 +37,6 @@
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "InspectorTimelineAgent.h"
#include "Page.h"
#include "PageGroup.h"
#include "ScriptController.h"
......
......@@ -39,7 +39,7 @@
#include "FrameLoaderClient.h"
#include "IDBFactoryBackendInterface.h"
#include "IDBPendingTransactionMonitor.h"
#include "InspectorTimelineAgent.h"
#include "InspectorInstrumentation.h"
#include "Page.h"
#include "PageGroup.h"
#include "PlatformBridge.h"
......@@ -376,10 +376,7 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
V8GCController::checkMemoryUsage();
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
timelineAgent->willEvaluateScript(source.url().isNull() ? String() : source.url().string(), source.startLine());
#endif
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, source.url().isNull() ? String() : source.url().string(), source.startLine());
v8::Local<v8::Value> result;
{
......@@ -414,10 +411,7 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
PlatformBridge::traceEventEnd("v8.run", node, "");
#endif
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
timelineAgent->didEvaluateScript();
#endif
InspectorInstrumentation::didEvaluateScript(m_frame, cookie);
return result;
}
......@@ -505,33 +499,23 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8
// execution finishs before firing the timer.
m_frame->keepAlive();
#if ENABLE(INSPECTOR)
Page* inspectedPage = InspectorTimelineAgent::instanceCount() ? m_frame->page(): 0;
if (inspectedPage) {
if (InspectorTimelineAgent* timelineAgent = inspectedPage->inspectorTimelineAgent()) {
v8::ScriptOrigin origin = function->GetScriptOrigin();
String resourceName("undefined");
int lineNumber = 1;
if (!origin.ResourceName().IsEmpty()) {
resourceName = toWebCoreString(origin.ResourceName());
lineNumber = function->GetScriptLineNumber() + 1;
}
timelineAgent->willCallFunction(resourceName, lineNumber);
} else
inspectedPage = 0;
InspectorInstrumentationCookie cookie = 0;
if (InspectorInstrumentation::hasFrontends()) {
v8::ScriptOrigin origin = function->GetScriptOrigin();
String resourceName("undefined");
int lineNumber = 1;
if (!origin.ResourceName().IsEmpty()) {
resourceName = toWebCoreString(origin.ResourceName());
lineNumber = function->GetScriptLineNumber() + 1;
}
cookie = InspectorInstrumentation::willCallFunction(m_frame, resourceName, lineNumber);
}
#endif // !ENABLE(INSPECTOR)
m_recursion++;
result = function->Call(receiver, argc, args);
m_recursion--;
#if ENABLE(INSPECTOR)
if (inspectedPage)
if (InspectorTimelineAgent* timelineAgent = inspectedPage->inspectorTimelineAgent())
timelineAgent->didCallFunction();
#endif // !ENABLE(INSPECTOR)
InspectorInstrumentation::didCallFunction(m_frame, cookie);
}
// Release the storage mutex if applicable.
......
......@@ -114,7 +114,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args)
INC_STATS("DOM.XMLHttpRequest.send()");
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());
InspectorInstrumentation::instrumentWillSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
ExceptionCode ec = 0;
if (args.Length() < 1)
......
......@@ -88,7 +88,7 @@
#include "HitTestResult.h"
#include "ImageLoader.h"
#include "InspectorController.h"
#include "InspectorTimelineAgent.h"
#include "InspectorInstrumentation.h"
#include "KeyboardEvent.h"
#include "Logging.h"
#include "MessageEvent.h"
......@@ -1460,10 +1460,7 @@ void Document::recalcStyle(StyleChange change)
if (m_inStyleRecalc)
return; // Guard against re-entrancy. -dwh
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
timelineAgent->willRecalculateStyle();
#endif
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(this);
m_inStyleRecalc = true;
suspendPostAttachCallbacks();
......@@ -1518,10 +1515,7 @@ bail_out:
implicitClose();
}
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
timelineAgent->didRecalculateStyle();
#endif
InspectorInstrumentation::didRecalculateStyle(this, cookie);
}
void Document::updateStyleIfNeeded()
......@@ -4685,18 +4679,6 @@ bool Document::isXHTMLMPDocument() const
}
#endif
#if ENABLE(INSPECTOR)
InspectorTimelineAgent* Document::inspectorTimelineAgent() const
{
return page() ? page()->inspectorTimelineAgent() : 0;
}
InspectorController* Document::inspectorController() const
{
return page() ? page()->inspectorController() : 0;
}
#endif
#if ENABLE(FULLSCREEN_API)
void Document::webkitRequestFullScreenForElement(Element* element, unsigned short flags)
{
......
......@@ -88,7 +88,6 @@ class HTMLInputElement;
class HTMLMapElement;
class HitTestRequest;
class HitTestResult;
class InspectorTimelineAgent;
class IntPoint;
class DOMWrapperWorld;
class JSNode;
......@@ -480,10 +479,6 @@ public:
Frame* frame() const { return m_frame; } // can be NULL
Page* page() const; // can be NULL
Settings* settings() const; // can be NULL
#if ENABLE(INSPECTOR)
InspectorTimelineAgent* inspectorTimelineAgent() const; // can be NULL
virtual InspectorController* inspectorController() const; // can be NULL
#endif
PassRefPtr<Range> createRange();
......
......@@ -2602,7 +2602,7 @@ bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent)
targetForWindowEvents = static_cast<Document*>(topLevelContainer)->domWindow();
}
int instrumentationCookie = InspectorInstrumentation::instrumentWillDispatchEvent(document(), *event, targetForWindowEvents, this, ancestors);
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(document(), *event, targetForWindowEvents, this, ancestors);
// Give the target node a chance to do some work before DOM event handlers get a crack.
void* data = preDispatchEventHandler(event.get());
......@@ -2685,7 +2685,7 @@ doneDispatching:
doneWithDefault:
InspectorInstrumentation::instrumentDidDispatchEvent(document(), instrumentationCookie);
InspectorInstrumentation::didDispatchEvent(document(), cookie);
return !event->defaultPrevented();
}
......
......@@ -36,15 +36,12 @@
#include "HTMLScriptRunner.h"
#include "HTMLTreeBuilder.h"
#include "HTMLDocument.h"
#include "InspectorInstrumentation.h"
#include "NestingLevelIncrementer.h"
#include "Settings.h"
#include "XSSAuditor.h"
#include <wtf/CurrentTime.h>
#if ENABLE(INSPECTOR)
#include "InspectorTimelineAgent.h"
#endif
namespace WebCore {
using namespace HTMLNames;
......@@ -210,9 +207,12 @@ void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
// ASSERT that this object is both attached to the Document and protected.
ASSERT(refCount() >= 2);
// We tell the InspectorTimelineAgent about every pump, even if we
// We tell the InspectorInstrumentation about every pump, even if we
// end up pumping nothing. It can filter out empty pumps itself.
willPumpLexer();
// FIXME: m_input.current().length() is only accurate if we
// end up parsing the whole buffer in this pump. We should pass how
// much we parsed as part of didWriteHTML instead of willWriteHTML.
InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteHTML(document(), m_input.current().length(), m_tokenizer->lineNumber());
HTMLParserScheduler::PumpSession session;
// FIXME: This loop body has is now too long and needs cleanup.
......@@ -256,26 +256,7 @@ void HTMLDocumentParser::pumpTokenizer(SynchronousMode mode)
m_preloadScanner->scan();
}
didPumpLexer();
}
void HTMLDocumentParser::willPumpLexer()
{
#if ENABLE(INSPECTOR)
// FIXME: m_input.current().length() is only accurate if we
// end up parsing the whole buffer in this pump. We should pass how
// much we parsed as part of didWriteHTML instead of willWriteHTML.
if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
timelineAgent->willWriteHTML(m_input.current().length(), m_tokenizer->lineNumber());
#endif
}
void HTMLDocumentParser::didPumpLexer()
{
#if ENABLE(INSPECTOR)
if (InspectorTimelineAgent* timelineAgent = document()->inspectorTimelineAgent())
timelineAgent->didWriteHTML(m_tokenizer->lineNumber());
#endif
InspectorInstrumentation::didWriteHTML(document(), m_tokenizer->lineNumber(), cookie);
}
bool HTMLDocumentParser::hasInsertionPoint()
......
......@@ -103,9 +103,6 @@ private:
// CachedResourceClient
virtual void notifyFinished(CachedResource*);
void willPumpLexer();
void didPumpLexer();
enum SynchronousMode {
AllowYield,
ForceSynchronous,
......
......@@ -39,6 +39,7 @@
#include "InspectorDOMAgent.h"
#include "InspectorDebuggerAgent.h"
#include "InspectorTimelineAgent.h"
#include "XMLHttpRequest.h"
namespace WebCore {
......@@ -64,8 +65,6 @@ static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window,
void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspectorController, Node* node, Node* parent)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (!inspectorController->hasFrontend())
return;
InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
if (!debuggerAgent)
return;
......@@ -80,8 +79,6 @@ void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspec
void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspectorController, Node* node)
{
if (!inspectorController->hasFrontend())
return;
if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
domAgent->didInsertDOMNode(node);
}
......@@ -89,8 +86,6 @@ void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspect
void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (!inspectorController->hasFrontend())
return;
InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
if (!debuggerAgent)
return;
......@@ -105,8 +100,6 @@ void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspec
void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node)
{
if (!inspectorController->hasFrontend())
return;
if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
domAgent->didRemoveDOMNode(node);
}
......@@ -114,8 +107,6 @@ void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspect
void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspectorController, Element* element)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (!inspectorController->hasFrontend())
return;
InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
if (!debuggerAgent)
return;
......@@ -130,27 +121,86 @@ void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspec
void InspectorInstrumentation::didModifyDOMAttrImpl(InspectorController* inspectorController, Element* element)
{
if (!inspectorController->hasFrontend())
return;
if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
domAgent->didModifyDOMAttr(element);
}
void InspectorInstrumentation::characterDataModifiedImpl(InspectorController* inspectorController, CharacterData* characterData)
{
if (!inspectorController->hasFrontend())
return;
if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
domAgent->characterDataModified(characterData);
}
int InspectorInstrumentation::instrumentWillDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
void InspectorInstrumentation::willSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
if (!debuggerAgent)
return;
if (!inspectorController->shouldBreakOnXMLHttpRequest(url))
return;
RefPtr<InspectorObject> eventData = InspectorObject::create();
eventData->setString("type", "XHR");
eventData->setString("url", url);
debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
#endif
}
void InspectorInstrumentation::didScheduleResourceRequestImpl(InspectorController* inspectorController, const String& url)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
timelineAgent->didScheduleResourceRequest(url);
}
void InspectorInstrumentation::didInstallTimerImpl(InspectorController* inspectorController, int timerId, int timeout, bool singleShot)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
timelineAgent->didInstallTimer(timerId, timeout, singleShot);
}
void InspectorInstrumentation::didRemoveTimerImpl(InspectorController* inspectorController, int timerId)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
timelineAgent->didRemoveTimer(timerId);
}
InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InspectorController* inspectorController, const String& scriptName, int scriptLine)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
timelineAgent->willCallFunction(scriptName, scriptLine);
return timelineAgent->id();
}
return 0;
}
void InspectorInstrumentation::didCallFunctionImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
int instrumentationCookie = 0;
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didCallFunction();
}
if (!inspectorController->hasFrontend())
return instrumentationCookie;
InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyStateImpl(InspectorController* inspectorController, XMLHttpRequest* request)
{
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
if (timelineAgent && request->hasEventListeners(eventNames().readystatechangeEvent)) {
timelineAgent->willChangeXHRReadyState(request->url().string(), request->readyState());
return timelineAgent->id();
}
return 0;
}
void InspectorInstrumentation::didChangeXHRReadyStateImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didChangeXHRReadyState();
}
InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get()) {
if (inspectorController->shouldBreakOnEvent(event.type())) {
......@@ -162,47 +212,194 @@ int InspectorInstrumentation::instrumentWillDispatchEventImpl(InspectorControlle
}
#endif
InspectorTimelineAgent* timelineAgent = inspectorController->m_timelineAgent.get();
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
if (timelineAgent && eventHasListeners(event.type(), window, node, ancestors)) {
timelineAgent->willDispatchEvent(event);
instrumentationCookie = timelineAgent->id();
return timelineAgent->id();
}
return instrumentationCookie;
return 0;
}
void InspectorInstrumentation::instrumentDidDispatchEventImpl(InspectorController* inspectorController, int instrumentationCookie)
void InspectorInstrumentation::didDispatchEventImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
if (!inspectorController->hasFrontend())
return;
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get())
debuggerAgent->cancelPauseOnNextStatement();
#endif
InspectorTimelineAgent* timelineAgent = inspectorController->m_timelineAgent.get();
if (timelineAgent && timelineAgent->id() == instrumentationCookie)
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didDispatchEvent();
}
void InspectorInstrumentation::instrumentWillSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url)
InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (!inspectorController->hasFrontend())
return;
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
if (timelineAgent && window->hasEventListeners(event.type())) {
timelineAgent->willDispatchEvent(event);
return timelineAgent->id();
}
return 0;
}
InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
if (!debuggerAgent)
return;
void InspectorInstrumentation::didDispatchEventOnWindowImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didDispatchEvent();
}
if (!inspectorController->shouldBreakOnXMLHttpRequest(url))
return;
InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScriptImpl(InspectorController* inspectorController, const String& url, int lineNumber)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
timelineAgent->willEvaluateScript(url, lineNumber);
return timelineAgent->id();
}
return 0;
}
RefPtr<InspectorObject> eventData = InspectorObject::create();
eventData->setString("type", "XHR");
eventData->setString("url", url);
debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
#endif
void InspectorInstrumentation::didEvaluateScriptImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didEvaluateScript();
}
InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InspectorController* inspectorController, int timerId)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
timelineAgent->willFireTimer(timerId);
return timelineAgent->id();
}
return 0;
}
void InspectorInstrumentation::didFireTimerImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didFireTimer();
}
InspectorInstrumentationCookie InspectorInstrumentation::willLayoutImpl(InspectorController* inspectorController)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController)) {
timelineAgent->willLayout();
return timelineAgent->id();
}
return 0;
}
void InspectorInstrumentation::didLayoutImpl(InspectorController* inspectorController, InspectorInstrumentationCookie cookie)
{
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController, cookie))
timelineAgent->didLayout();
}
InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHRImpl(InspectorController* inspectorController, XMLHttpRequest* request)
{
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
if (timelineAgent && request->hasEventListeners(eventNames().loadEvent)) {
timelineAgent->willLoadXHR(request->url().string());
return timelineAgent->id();
}
return 0;