Skip to content
Permalink
Browse files
2010-10-14 Pavel Podivilov <podivilov@chromium.org>
        Reviewed by Pavel Feldman.

        Web Inspector: implement pausing on window events and timeouts
        https://bugs.webkit.org/show_bug.cgi?id=47542

        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::didInstallTimerImpl):
        (WebCore::InspectorInstrumentation::didRemoveTimerImpl):
        (WebCore::InspectorInstrumentation::willDispatchEventImpl):
        (WebCore::InspectorInstrumentation::didDispatchEventImpl):
        (WebCore::InspectorInstrumentation::willDispatchEventOnWindowImpl):
        (WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
        (WebCore::InspectorInstrumentation::willFireTimerImpl):
        (WebCore::InspectorInstrumentation::didFireTimerImpl):
        (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded):
        (WebCore::InspectorInstrumentation::cancelPauseOnNativeEvent):
        * inspector/InspectorInstrumentation.h:
        * inspector/front-end/BreakpointManager.js:
        (WebInspector.EventListenerBreakpoint.prototype.populateLabelElement):
        (WebInspector.EventListenerBreakpoint.prototype.populateStatusMessageElement):
        (WebInspector.EventListenerBreakpoint.prototype._condition):
        (WebInspector.EventListenerBreakpoint.prototype._uiEventName):
        * inspector/front-end/BreakpointsSidebarPane.js:
        (WebInspector.EventListenerBreakpointsSidebarPane.prototype._populate):

Canonical link: https://commits.webkit.org/60347@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Pavel Podivilov committed Oct 14, 2010
1 parent 53be20f commit 396a60e0e692a61e1ba2397e5af8939a290571cd
Showing 6 changed files with 100 additions and 23 deletions.
@@ -1,3 +1,30 @@
2010-10-14 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: implement pausing on window events and timeouts
https://bugs.webkit.org/show_bug.cgi?id=47542

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didInstallTimerImpl):
(WebCore::InspectorInstrumentation::didRemoveTimerImpl):
(WebCore::InspectorInstrumentation::willDispatchEventImpl):
(WebCore::InspectorInstrumentation::didDispatchEventImpl):
(WebCore::InspectorInstrumentation::willDispatchEventOnWindowImpl):
(WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
(WebCore::InspectorInstrumentation::willFireTimerImpl):
(WebCore::InspectorInstrumentation::didFireTimerImpl):
(WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded):
(WebCore::InspectorInstrumentation::cancelPauseOnNativeEvent):
* inspector/InspectorInstrumentation.h:
* inspector/front-end/BreakpointManager.js:
(WebInspector.EventListenerBreakpoint.prototype.populateLabelElement):
(WebInspector.EventListenerBreakpoint.prototype.populateStatusMessageElement):
(WebInspector.EventListenerBreakpoint.prototype._condition):
(WebInspector.EventListenerBreakpoint.prototype._uiEventName):
* inspector/front-end/BreakpointsSidebarPane.js:
(WebInspector.EventListenerBreakpointsSidebarPane.prototype._populate):

2010-10-14 Csaba Osztrogonác <ossy@webkit.org>

Reviewed by Andreas Kling.
Binary file not shown.
@@ -43,6 +43,13 @@

namespace WebCore {

static const char* const listenerEventCategoryType = "listener";
static const char* const instrumentationEventCategoryType = "instrumentation";

static const char* const setTimerEventName = "setTimer";
static const char* const clearTimerEventName = "clearTimer";
static const char* const timerFiredEventName = "timerFired";

int InspectorInstrumentation::s_frontendCounter = 0;

static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
@@ -158,12 +165,14 @@ void InspectorInstrumentation::didScheduleResourceRequestImpl(InspectorControlle

void InspectorInstrumentation::didInstallTimerImpl(InspectorController* inspectorController, int timerId, int timeout, bool singleShot)
{
pauseOnNativeEventIfNeeded(inspectorController, instrumentationEventCategoryType, setTimerEventName, true);
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
timelineAgent->didInstallTimer(timerId, timeout, singleShot);
}

void InspectorInstrumentation::didRemoveTimerImpl(InspectorController* inspectorController, int timerId)
{
pauseOnNativeEventIfNeeded(inspectorController, instrumentationEventCategoryType, clearTimerEventName, true);
if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
timelineAgent->didRemoveTimer(timerId);
}
@@ -205,17 +214,7 @@ void InspectorInstrumentation::didChangeXHRReadyStateImpl(const InspectorInstrum

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()) {
String breakpointId = inspectorController->findEventListenerBreakpoint(event.type());
if (!breakpointId.isEmpty()) {
RefPtr<InspectorObject> eventData = InspectorObject::create();
eventData->setString("breakpointId", breakpointId);
eventData->setString("eventName", event.type());
debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData);
}
}
#endif
pauseOnNativeEventIfNeeded(inspectorController, listenerEventCategoryType, event.type(), false);

int timelineAgentId = 0;
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
@@ -228,17 +227,16 @@ InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(I

void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (InspectorDebuggerAgent* debuggerAgent = cookie.first->m_debuggerAgent.get())
debuggerAgent->cancelPauseOnNextStatement();
#endif
cancelPauseOnNativeEvent(cookie.first);

if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
timelineAgent->didDispatchEvent();
}

InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window)
{
pauseOnNativeEventIfNeeded(inspectorController, listenerEventCategoryType, event.type(), false);

int timelineAgentId = 0;
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
if (timelineAgent && window->hasEventListeners(event.type())) {
@@ -250,6 +248,8 @@ InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWind

void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
{
cancelPauseOnNativeEvent(cookie.first);

if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
timelineAgent->didDispatchEvent();
}
@@ -273,6 +273,8 @@ void InspectorInstrumentation::didEvaluateScriptImpl(const InspectorInstrumentat

InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InspectorController* inspectorController, int timerId)
{
pauseOnNativeEventIfNeeded(inspectorController, instrumentationEventCategoryType, timerFiredEventName, false);

int timelineAgentId = 0;
InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
if (timelineAgent) {
@@ -284,6 +286,8 @@ InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(Inspe

void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCookie& cookie)
{
cancelPauseOnNativeEvent(cookie.first);

if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
timelineAgent->didFireTimer();
}
@@ -412,6 +416,33 @@ bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorControl
return inspectorController->hasFrontend();
}

void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InspectorController* inspectorController, const String& categoryType, const String& eventName, bool synchronous)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
if (!debuggerAgent)
return;
String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data());
String breakpointId = inspectorController->findEventListenerBreakpoint(fullEventName);
if (breakpointId.isEmpty())
return;
RefPtr<InspectorObject> eventData = InspectorObject::create();
eventData->setString("breakpointId", breakpointId);
if (synchronous)
debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
else
debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData);
#endif
}

void InspectorInstrumentation::cancelPauseOnNativeEvent(InspectorController* inspectorController)
{
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get())
debuggerAgent->cancelPauseOnNextStatement();
#endif
}

InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(InspectorController* inspectorController)
{
return inspectorController->m_timelineAgent.get();
@@ -146,6 +146,8 @@ class InspectorInstrumentation {
static InspectorController* inspectorControllerForPage(Page*);

static bool hasFrontend(InspectorController*);
static void pauseOnNativeEventIfNeeded(InspectorController*, const String& categoryType, const String& eventName, bool synchronous);
static void cancelPauseOnNativeEvent(InspectorController*);
static InspectorTimelineAgent* retrieveTimelineAgent(InspectorController*);
static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);

@@ -486,20 +486,32 @@ WebInspector.EventListenerBreakpoint.prototype = {
return this._compare(this._eventName, other._eventName);
},

label: function()
populateLabelElement: function(element)
{
return this._eventName;
element.appendChild(document.createTextNode(this._uiEventName()));
},

populateStatusMessageElement: function(element, eventData)
{
var status = WebInspector.UIString("Paused on a \"%s\" Event Listener.", this._eventName);
var status = WebInspector.UIString("Paused on a \"%s\" Event Listener.", this._uiEventName());
element.appendChild(document.createTextNode(status));
},

_condition: function()
{
return { eventName: this._eventName };
},

_uiEventName: function()
{
if (!WebInspector.EventListenerBreakpoint._uiEventNames) {
WebInspector.EventListenerBreakpoint._uiEventNames = {
"instrumentation:setTimer": WebInspector.UIString("Set Timer"),
"instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
"instrumentation:timerFired": WebInspector.UIString("Timer Fired")
};
}
return WebInspector.EventListenerBreakpoint._uiEventNames[this._eventName] || this._eventName.substring(this._eventName.indexOf(":") + 1);
}
}

@@ -246,8 +246,10 @@ WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
_populate: function()
{
var categories = {
"Mouse": ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"],
"Keyboard": ["keydown", "keypress", "keyup"]
"Mouse": { type: "listener", eventNames: ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"] },
"Keyboard": { type: "listener", eventNames: ["keydown", "keypress", "keyup"] },
"HTML frame/object": { type: "listener", eventNames: ["load", "error", "resize", "scroll"] },
"Timer": { type: "instrumentation", eventNames: ["setTimer", "clearTimer", "timerFired"] }
};

for (var category in categories) {
@@ -260,15 +262,18 @@ WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
categoryItem.checkbox = this._createCheckbox(categoryTreeElement, this._categoryCheckboxClicked.bind(this, categoryItem));
categoryItem.children = {};

var eventNames = categories[category];
var categoryType = categories[category].type;
var eventNames = categories[category].eventNames;
for (var i = 0; i < eventNames.length; ++i) {
var eventName = eventNames[i];
var eventName = categoryType + ":" + eventNames[i];

var breakpoint = WebInspector.breakpointManager.createEventListenerBreakpoint(eventName, true);
if (!breakpoint)
continue;

var eventNameTreeElement = new TreeElement(breakpoint.label());
var labelElement = document.createElement("div");
breakpoint.populateLabelElement(labelElement);
var eventNameTreeElement = new TreeElement(labelElement);
categoryTreeElement.appendChild(eventNameTreeElement);
eventNameTreeElement.listItemElement.addStyleClass("source-code");
eventNameTreeElement.selectable = true;

0 comments on commit 396a60e

Please sign in to comment.