Changeset 69760 in webkit


Ignore:
Timestamp:
Oct 14, 2010 5:56:28 AM (14 years ago)
Author:
podivilov@chromium.org
Message:

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):
Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69759 r69760  
     12010-10-14  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: implement pausing on window events and timeouts
     6        https://bugs.webkit.org/show_bug.cgi?id=47542
     7
     8        * inspector/InspectorInstrumentation.cpp:
     9        (WebCore::InspectorInstrumentation::didInstallTimerImpl):
     10        (WebCore::InspectorInstrumentation::didRemoveTimerImpl):
     11        (WebCore::InspectorInstrumentation::willDispatchEventImpl):
     12        (WebCore::InspectorInstrumentation::didDispatchEventImpl):
     13        (WebCore::InspectorInstrumentation::willDispatchEventOnWindowImpl):
     14        (WebCore::InspectorInstrumentation::didDispatchEventOnWindowImpl):
     15        (WebCore::InspectorInstrumentation::willFireTimerImpl):
     16        (WebCore::InspectorInstrumentation::didFireTimerImpl):
     17        (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded):
     18        (WebCore::InspectorInstrumentation::cancelPauseOnNativeEvent):
     19        * inspector/InspectorInstrumentation.h:
     20        * inspector/front-end/BreakpointManager.js:
     21        (WebInspector.EventListenerBreakpoint.prototype.populateLabelElement):
     22        (WebInspector.EventListenerBreakpoint.prototype.populateStatusMessageElement):
     23        (WebInspector.EventListenerBreakpoint.prototype._condition):
     24        (WebInspector.EventListenerBreakpoint.prototype._uiEventName):
     25        * inspector/front-end/BreakpointsSidebarPane.js:
     26        (WebInspector.EventListenerBreakpointsSidebarPane.prototype._populate):
     27
    1282010-10-14  Csaba Osztrogonác  <ossy@webkit.org>
    229
  • trunk/WebCore/inspector/InspectorInstrumentation.cpp

    r69567 r69760  
    4444namespace WebCore {
    4545
     46static const char* const listenerEventCategoryType = "listener";
     47static const char* const instrumentationEventCategoryType = "instrumentation";
     48
     49static const char* const setTimerEventName = "setTimer";
     50static const char* const clearTimerEventName = "clearTimer";
     51static const char* const timerFiredEventName = "timerFired";
     52
    4653int InspectorInstrumentation::s_frontendCounter = 0;
    4754
     
    159166void InspectorInstrumentation::didInstallTimerImpl(InspectorController* inspectorController, int timerId, int timeout, bool singleShot)
    160167{
     168    pauseOnNativeEventIfNeeded(inspectorController, instrumentationEventCategoryType, setTimerEventName, true);
    161169    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
    162170        timelineAgent->didInstallTimer(timerId, timeout, singleShot);
     
    165173void InspectorInstrumentation::didRemoveTimerImpl(InspectorController* inspectorController, int timerId)
    166174{
     175    pauseOnNativeEventIfNeeded(inspectorController, instrumentationEventCategoryType, clearTimerEventName, true);
    167176    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController))
    168177        timelineAgent->didRemoveTimer(timerId);
     
    206215InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window, Node* node, const Vector<RefPtr<ContainerNode> >& ancestors)
    207216{
    208 #if ENABLE(JAVASCRIPT_DEBUGGER)
    209     if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get()) {
    210         String breakpointId = inspectorController->findEventListenerBreakpoint(event.type());
    211         if (!breakpointId.isEmpty()) {
    212             RefPtr<InspectorObject> eventData = InspectorObject::create();
    213             eventData->setString("breakpointId", breakpointId);
    214             eventData->setString("eventName", event.type());
    215             debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData);
    216         }
    217     }
    218 #endif
     217    pauseOnNativeEventIfNeeded(inspectorController, listenerEventCategoryType, event.type(), false);
    219218
    220219    int timelineAgentId = 0;
     
    229228void InspectorInstrumentation::didDispatchEventImpl(const InspectorInstrumentationCookie& cookie)
    230229{
    231 #if ENABLE(JAVASCRIPT_DEBUGGER)
    232     if (InspectorDebuggerAgent* debuggerAgent = cookie.first->m_debuggerAgent.get())
    233         debuggerAgent->cancelPauseOnNextStatement();
    234 #endif
     230    cancelPauseOnNativeEvent(cookie.first);
    235231
    236232    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
     
    240236InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindowImpl(InspectorController* inspectorController, const Event& event, DOMWindow* window)
    241237{
     238    pauseOnNativeEventIfNeeded(inspectorController, listenerEventCategoryType, event.type(), false);
     239
    242240    int timelineAgentId = 0;
    243241    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
     
    251249void InspectorInstrumentation::didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie& cookie)
    252250{
     251    cancelPauseOnNativeEvent(cookie.first);
     252
    253253    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    254254        timelineAgent->didDispatchEvent();
     
    274274InspectorInstrumentationCookie InspectorInstrumentation::willFireTimerImpl(InspectorController* inspectorController, int timerId)
    275275{
     276    pauseOnNativeEventIfNeeded(inspectorController, instrumentationEventCategoryType, timerFiredEventName, false);
     277
    276278    int timelineAgentId = 0;
    277279    InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(inspectorController);
     
    285287void InspectorInstrumentation::didFireTimerImpl(const InspectorInstrumentationCookie& cookie)
    286288{
     289    cancelPauseOnNativeEvent(cookie.first);
     290
    287291    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
    288292        timelineAgent->didFireTimer();
     
    411415{
    412416    return inspectorController->hasFrontend();
     417}
     418
     419void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InspectorController* inspectorController, const String& categoryType, const String& eventName, bool synchronous)
     420{
     421#if ENABLE(JAVASCRIPT_DEBUGGER)
     422    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
     423    if (!debuggerAgent)
     424        return;
     425    String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data());
     426    String breakpointId = inspectorController->findEventListenerBreakpoint(fullEventName);
     427    if (breakpointId.isEmpty())
     428        return;
     429    RefPtr<InspectorObject> eventData = InspectorObject::create();
     430    eventData->setString("breakpointId", breakpointId);
     431    if (synchronous)
     432        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
     433    else
     434        debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData);
     435#endif
     436}
     437
     438void InspectorInstrumentation::cancelPauseOnNativeEvent(InspectorController* inspectorController)
     439{
     440#if ENABLE(JAVASCRIPT_DEBUGGER)
     441    if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get())
     442        debuggerAgent->cancelPauseOnNextStatement();
     443#endif
    413444}
    414445
  • trunk/WebCore/inspector/InspectorInstrumentation.h

    r69406 r69760  
    147147
    148148    static bool hasFrontend(InspectorController*);
     149    static void pauseOnNativeEventIfNeeded(InspectorController*, const String& categoryType, const String& eventName, bool synchronous);
     150    static void cancelPauseOnNativeEvent(InspectorController*);
    149151    static InspectorTimelineAgent* retrieveTimelineAgent(InspectorController*);
    150152    static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
  • trunk/WebCore/inspector/front-end/BreakpointManager.js

    r69567 r69760  
    487487    },
    488488
    489     label: function()
    490     {
    491         return this._eventName;
     489    populateLabelElement: function(element)
     490    {
     491        element.appendChild(document.createTextNode(this._uiEventName()));
    492492    },
    493493
    494494    populateStatusMessageElement: function(element, eventData)
    495495    {
    496         var status = WebInspector.UIString("Paused on a \"%s\" Event Listener.", this._eventName);
     496        var status = WebInspector.UIString("Paused on a \"%s\" Event Listener.", this._uiEventName());
    497497        element.appendChild(document.createTextNode(status));
    498498    },
     
    501501    {
    502502        return { eventName: this._eventName };
     503    },
     504
     505    _uiEventName: function()
     506    {
     507        if (!WebInspector.EventListenerBreakpoint._uiEventNames) {
     508            WebInspector.EventListenerBreakpoint._uiEventNames = {
     509                "instrumentation:setTimer": WebInspector.UIString("Set Timer"),
     510                "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
     511                "instrumentation:timerFired": WebInspector.UIString("Timer Fired")
     512            };
     513        }
     514        return WebInspector.EventListenerBreakpoint._uiEventNames[this._eventName] || this._eventName.substring(this._eventName.indexOf(":") + 1);
    503515    }
    504516}
  • trunk/WebCore/inspector/front-end/BreakpointsSidebarPane.js

    r69567 r69760  
    247247    {
    248248        var categories = {
    249             "Mouse": ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"],
    250             "Keyboard": ["keydown", "keypress", "keyup"]
     249            "Mouse": { type: "listener", eventNames: ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel"] },
     250            "Keyboard": { type: "listener", eventNames: ["keydown", "keypress", "keyup"] },
     251            "HTML frame/object":  { type: "listener", eventNames: ["load", "error", "resize", "scroll"] },
     252            "Timer": { type: "instrumentation", eventNames: ["setTimer", "clearTimer", "timerFired"] }
    251253        };
    252254
     
    261263            categoryItem.children = {};
    262264
    263             var eventNames = categories[category];
     265            var categoryType = categories[category].type;
     266            var eventNames = categories[category].eventNames;
    264267            for (var i = 0; i < eventNames.length; ++i) {
    265                 var eventName = eventNames[i];
     268                var eventName = categoryType + ":" + eventNames[i];
    266269
    267270                var breakpoint = WebInspector.breakpointManager.createEventListenerBreakpoint(eventName, true);
     
    269272                    continue;
    270273
    271                 var eventNameTreeElement = new TreeElement(breakpoint.label());
     274                var labelElement = document.createElement("div");
     275                breakpoint.populateLabelElement(labelElement);
     276                var eventNameTreeElement = new TreeElement(labelElement);
    272277                categoryTreeElement.appendChild(eventNameTreeElement);
    273278                eventNameTreeElement.listItemElement.addStyleClass("source-code");
Note: See TracChangeset for help on using the changeset viewer.