Changeset 69567 in webkit


Ignore:
Timestamp:
Oct 12, 2010 2:35:27 AM (14 years ago)
Author:
podivilov@chromium.org
Message:

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

Reviewed by Pavel Feldman.

Web Inspector: refactoring of native breakpoints.
https://bugs.webkit.org/show_bug.cgi?id=47360

Make DOM, EventListener and XHR breakpoints subclasses of NativeBreakpoint class.
Move stuff that depends on breakpoint type to corresponding subclass.

  • inspector/Inspector.idl:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::didCommitLoad): (WebCore::InspectorController::setNativeBreakpoint): (WebCore::InspectorController::removeNativeBreakpoint): (WebCore::InspectorController::findEventListenerBreakpoint): (WebCore::InspectorController::findXHRBreakpoint):
  • inspector/InspectorController.h:
  • inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::setDOMBreakpoint): (WebCore::InspectorDOMAgent::removeDOMBreakpoint): (WebCore::InspectorDOMAgent::descriptionForDOMEvent): (WebCore::InspectorDOMAgent::didRemoveDOMNode): (WebCore::InspectorDOMAgent::removeBreakpointsForNode): (WebCore::InspectorDOMAgent::createBreakpointId):
  • inspector/InspectorDOMAgent.h:
  • inspector/InspectorDebuggerAgent.h:
  • inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl): (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl): (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl): (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl): (WebCore::InspectorInstrumentation::willDispatchEventImpl):
  • inspector/front-end/BreakpointManager.js: (WebInspector.BreakpointManager): (WebInspector.BreakpointManager.prototype.reset): (WebInspector.BreakpointManager.prototype.createDOMBreakpoint): (WebInspector.BreakpointManager.prototype.createEventListenerBreakpoint): (WebInspector.BreakpointManager.prototype.createXHRBreakpoint): (WebInspector.BreakpointManager.prototype._removeNativeBreakpoint): (WebInspector.BreakpointManager.prototype._setNativeBreakpointOnBackend.didSetNativeBreakpoint): (WebInspector.BreakpointManager.prototype._setNativeBreakpointOnBackend): (WebInspector.BreakpointManager.prototype.debuggerPaused): (WebInspector.BreakpointManager.prototype.debuggerResumed): (WebInspector.BreakpointManager.prototype.restoreDOMBreakpoints.restoreBreakpointsForNode): (WebInspector.BreakpointManager.prototype.restoreDOMBreakpoints): (WebInspector.NativeBreakpoint): (WebInspector.NativeBreakpoint.prototype.remove): (WebInspector.NativeBreakpoint.prototype.get _frontendId): (WebInspector.NativeBreakpoint.prototype.get _type): (WebInspector.NativeBreakpoint.prototype._compare): (WebInspector.NativeBreakpoint.prototype._onRemove): (WebInspector.DOMBreakpoint): (WebInspector.DOMBreakpoint.prototype.click): (WebInspector.DOMBreakpoint.prototype.compareTo): (WebInspector.DOMBreakpoint.prototype.populateLabelElement): (WebInspector.DOMBreakpoint.prototype.populateStatusMessageElement.formatters.s): (WebInspector.DOMBreakpoint.prototype.populateStatusMessageElement.append): (WebInspector.DOMBreakpoint.prototype.populateStatusMessageElement): (WebInspector.DOMBreakpoint.prototype._condition): (WebInspector.DOMBreakpoint.prototype._onRemove): (WebInspector.EventListenerBreakpoint): (WebInspector.EventListenerBreakpoint.prototype.compareTo): (WebInspector.EventListenerBreakpoint.prototype.label): (WebInspector.EventListenerBreakpoint.prototype.populateStatusMessageElement): (WebInspector.EventListenerBreakpoint.prototype._condition): (WebInspector.XHRBreakpoint): (WebInspector.XHRBreakpoint.prototype.compareTo): (WebInspector.XHRBreakpoint.prototype.populateLabelElement): (WebInspector.XHRBreakpoint.prototype.populateStatusMessageElement): (WebInspector.XHRBreakpoint.prototype._condition): (WebInspector.domBreakpointTypeLabel): (WebInspector.domBreakpointTypeContextMenuLabel):
  • inspector/front-end/BreakpointsSidebarPane.js: (WebInspector.BreakpointItem): (WebInspector.BreakpointItem.prototype._breakpointClicked): (WebInspector.EventListenerBreakpointsSidebarPane.prototype._populate):
  • inspector/front-end/CallStackSidebarPane.js: (WebInspector.CallStackSidebarPane): (WebInspector.CallStackSidebarPane.prototype.registerShortcuts): (WebInspector.CallStackSidebarPane.prototype._breakpointHit):
  • inspector/front-end/DOMAgent.js: (WebInspector.DOMNode): (WebInspector.DOMAgent.prototype._setDocument): (WebInspector.DOMAgent.prototype._removeBreakpoints): (WebInspector.childNodeRemoved):
  • inspector/front-end/ElementsTreeOutline.js: (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype.debuggerPaused):
  • inspector/front-end/inspector.js: (WebInspector.createDOMBreakpointsSidebarPane.breakpointAdded): (WebInspector.createDOMBreakpointsSidebarPane): (WebInspector.reset):
Location:
trunk/WebCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69560 r69567  
     12010-10-07  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: refactoring of native breakpoints.
     6        https://bugs.webkit.org/show_bug.cgi?id=47360
     7
     8        Make DOM, EventListener and XHR breakpoints subclasses of NativeBreakpoint class.
     9        Move stuff that depends on breakpoint type to corresponding subclass.
     10
     11        * inspector/Inspector.idl:
     12        * inspector/InspectorController.cpp:
     13        (WebCore::InspectorController::didCommitLoad):
     14        (WebCore::InspectorController::setNativeBreakpoint):
     15        (WebCore::InspectorController::removeNativeBreakpoint):
     16        (WebCore::InspectorController::findEventListenerBreakpoint):
     17        (WebCore::InspectorController::findXHRBreakpoint):
     18        * inspector/InspectorController.h:
     19        * inspector/InspectorDOMAgent.cpp:
     20        (WebCore::InspectorDOMAgent::setDOMBreakpoint):
     21        (WebCore::InspectorDOMAgent::removeDOMBreakpoint):
     22        (WebCore::InspectorDOMAgent::descriptionForDOMEvent):
     23        (WebCore::InspectorDOMAgent::didRemoveDOMNode):
     24        (WebCore::InspectorDOMAgent::removeBreakpointsForNode):
     25        (WebCore::InspectorDOMAgent::createBreakpointId):
     26        * inspector/InspectorDOMAgent.h:
     27        * inspector/InspectorDebuggerAgent.h:
     28        * inspector/InspectorInstrumentation.cpp:
     29        (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl):
     30        (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl):
     31        (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl):
     32        (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl):
     33        (WebCore::InspectorInstrumentation::willDispatchEventImpl):
     34        * inspector/front-end/BreakpointManager.js:
     35        (WebInspector.BreakpointManager):
     36        (WebInspector.BreakpointManager.prototype.reset):
     37        (WebInspector.BreakpointManager.prototype.createDOMBreakpoint):
     38        (WebInspector.BreakpointManager.prototype.createEventListenerBreakpoint):
     39        (WebInspector.BreakpointManager.prototype.createXHRBreakpoint):
     40        (WebInspector.BreakpointManager.prototype._removeNativeBreakpoint):
     41        (WebInspector.BreakpointManager.prototype._setNativeBreakpointOnBackend.didSetNativeBreakpoint):
     42        (WebInspector.BreakpointManager.prototype._setNativeBreakpointOnBackend):
     43        (WebInspector.BreakpointManager.prototype.debuggerPaused):
     44        (WebInspector.BreakpointManager.prototype.debuggerResumed):
     45        (WebInspector.BreakpointManager.prototype.restoreDOMBreakpoints.restoreBreakpointsForNode):
     46        (WebInspector.BreakpointManager.prototype.restoreDOMBreakpoints):
     47        (WebInspector.NativeBreakpoint):
     48        (WebInspector.NativeBreakpoint.prototype.remove):
     49        (WebInspector.NativeBreakpoint.prototype.get _frontendId):
     50        (WebInspector.NativeBreakpoint.prototype.get _type):
     51        (WebInspector.NativeBreakpoint.prototype._compare):
     52        (WebInspector.NativeBreakpoint.prototype._onRemove):
     53        (WebInspector.DOMBreakpoint):
     54        (WebInspector.DOMBreakpoint.prototype.click):
     55        (WebInspector.DOMBreakpoint.prototype.compareTo):
     56        (WebInspector.DOMBreakpoint.prototype.populateLabelElement):
     57        (WebInspector.DOMBreakpoint.prototype.populateStatusMessageElement.formatters.s):
     58        (WebInspector.DOMBreakpoint.prototype.populateStatusMessageElement.append):
     59        (WebInspector.DOMBreakpoint.prototype.populateStatusMessageElement):
     60        (WebInspector.DOMBreakpoint.prototype._condition):
     61        (WebInspector.DOMBreakpoint.prototype._onRemove):
     62        (WebInspector.EventListenerBreakpoint):
     63        (WebInspector.EventListenerBreakpoint.prototype.compareTo):
     64        (WebInspector.EventListenerBreakpoint.prototype.label):
     65        (WebInspector.EventListenerBreakpoint.prototype.populateStatusMessageElement):
     66        (WebInspector.EventListenerBreakpoint.prototype._condition):
     67        (WebInspector.XHRBreakpoint):
     68        (WebInspector.XHRBreakpoint.prototype.compareTo):
     69        (WebInspector.XHRBreakpoint.prototype.populateLabelElement):
     70        (WebInspector.XHRBreakpoint.prototype.populateStatusMessageElement):
     71        (WebInspector.XHRBreakpoint.prototype._condition):
     72        (WebInspector.domBreakpointTypeLabel):
     73        (WebInspector.domBreakpointTypeContextMenuLabel):
     74        * inspector/front-end/BreakpointsSidebarPane.js:
     75        (WebInspector.BreakpointItem):
     76        (WebInspector.BreakpointItem.prototype._breakpointClicked):
     77        (WebInspector.EventListenerBreakpointsSidebarPane.prototype._populate):
     78        * inspector/front-end/CallStackSidebarPane.js:
     79        (WebInspector.CallStackSidebarPane):
     80        (WebInspector.CallStackSidebarPane.prototype.registerShortcuts):
     81        (WebInspector.CallStackSidebarPane.prototype._breakpointHit):
     82        * inspector/front-end/DOMAgent.js:
     83        (WebInspector.DOMNode):
     84        (WebInspector.DOMAgent.prototype._setDocument):
     85        (WebInspector.DOMAgent.prototype._removeBreakpoints):
     86        (WebInspector.childNodeRemoved):
     87        * inspector/front-end/ElementsTreeOutline.js:
     88        (WebInspector.ElementsTreeElement.prototype._populateTagContextMenu):
     89        * inspector/front-end/ScriptsPanel.js:
     90        (WebInspector.ScriptsPanel.prototype.debuggerPaused):
     91        * inspector/front-end/inspector.js:
     92        (WebInspector.createDOMBreakpointsSidebarPane.breakpointAdded):
     93        (WebInspector.createDOMBreakpointsSidebarPane):
     94        (WebInspector.reset):
     95
    1962010-10-11  Eric Uhrhane  <ericu@chromium.org>
    297
  • trunk/WebCore/inspector/Inspector.idl

    r69185 r69567  
    136136        [handler=Debug] void getScriptSource(in String sourceID, out String scriptSource);
    137137
    138         [handler=Controller] void setNativeBreakpoint(in Object breakpoint, out unsigned int breakpointId);
    139         [handler=Controller] void removeNativeBreakpoint(in unsigned int breakpointId);
     138        [handler=Controller] void setNativeBreakpoint(in Object breakpoint, out String breakpointId);
     139        [handler=Controller] void removeNativeBreakpoint(in String breakpointId);
    140140
    141141        [handler=Controller] void enableProfiler(in boolean always);
     
    172172        [handler=DOM] void searchCanceled();
    173173        [handler=DOM] void pushNodeByPathToFrontend(in String path, out long nodeId);
    174         [handler=DOM] void setDOMBreakpoint(in long nodeId, in long type);
    175         [handler=DOM] void removeDOMBreakpoint(in long nodeId, in long type);
    176174
    177175        [handler=Controller] void clearConsoleMessages();
  • trunk/WebCore/inspector/InspectorController.cpp

    r69300 r69567  
    133133static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight";
    134134
     135static const char* const domNativeBreakpointType = "DOM";
     136static const char* const eventListenerNativeBreakpointType = "EventListener";
    135137static const char* const xhrNativeBreakpointType = "XHR";
    136 static const char* const eventListenerNativeBreakpointType = "EventListener";
    137138
    138139const char* const InspectorController::ElementsPanel = "elements";
     
    789790        m_nativeBreakpoints.clear();
    790791        m_eventListenerBreakpoints.clear();
    791         m_eventNameToBreakpointId.clear();
    792792        m_XHRBreakpoints.clear();
    793793        m_lastBreakpointId = 0;
     
    16801680}
    16811681
    1682 void InspectorController::setNativeBreakpoint(PassRefPtr<InspectorObject> breakpoint, unsigned int* breakpointId)
    1683 {
    1684     *breakpointId = 0;
     1682void InspectorController::setNativeBreakpoint(PassRefPtr<InspectorObject> breakpoint, String* breakpointId)
     1683{
     1684    *breakpointId = "";
    16851685    String type;
    16861686    if (!breakpoint->getString("type", &type))
     
    16931693        if (!condition->getString("url", &url))
    16941694            return;
    1695         *breakpointId = ++m_lastBreakpointId;
    1696         m_nativeBreakpoints.set(*breakpointId, "XHR");
     1695        *breakpointId = String::number(++m_lastBreakpointId);
    16971696        m_XHRBreakpoints.set(*breakpointId, url);
     1697        m_nativeBreakpoints.set(*breakpointId, type);
    16981698    } else if (type == eventListenerNativeBreakpointType) {
    16991699        String eventName;
    17001700        if (!condition->getString("eventName", &eventName))
    17011701            return;
    1702         if (m_eventNameToBreakpointId.contains(eventName))
     1702        if (m_eventListenerBreakpoints.contains(eventName))
    17031703            return;
    1704         *breakpointId = ++m_lastBreakpointId;
    1705         m_nativeBreakpoints.set(*breakpointId, "EventListener");
    1706         m_eventListenerBreakpoints.set(*breakpointId, eventName);
    1707         m_eventNameToBreakpointId.set(eventName, *breakpointId);
    1708     }
    1709 }
    1710 
    1711 void InspectorController::removeNativeBreakpoint(unsigned int breakpointId)
     1704        *breakpointId = eventName;
     1705        m_eventListenerBreakpoints.add(eventName);
     1706        m_nativeBreakpoints.set(*breakpointId, type);
     1707    } else if (type == domNativeBreakpointType) {
     1708        if (!m_domAgent)
     1709            return;
     1710        double nodeIdNumber;
     1711        if (!condition->getNumber("nodeId", &nodeIdNumber))
     1712            return;
     1713        double domBreakpointTypeNumber;
     1714        if (!condition->getNumber("type", &domBreakpointTypeNumber))
     1715            return;
     1716        long nodeId = (long) nodeIdNumber;
     1717        long domBreakpointType = (long) domBreakpointTypeNumber;
     1718        *breakpointId = m_domAgent->setDOMBreakpoint(nodeId, domBreakpointType);
     1719        if (!breakpointId->isEmpty())
     1720            m_nativeBreakpoints.set(*breakpointId, type);
     1721    }
     1722}
     1723
     1724void InspectorController::removeNativeBreakpoint(const String& breakpointId)
    17121725{
    17131726    String type = m_nativeBreakpoints.take(breakpointId);
    17141727    if (type == xhrNativeBreakpointType)
    17151728        m_XHRBreakpoints.remove(breakpointId);
    1716     else if (type == eventListenerNativeBreakpointType) {
    1717         String eventName = m_eventListenerBreakpoints.take(breakpointId);
    1718         m_eventNameToBreakpointId.remove(eventName);
    1719     }
    1720 }
    1721 
    1722 unsigned int InspectorController::findEventListenerBreakpoint(const String& eventName)
    1723 {
    1724     return m_eventNameToBreakpointId.get(eventName);
    1725 }
    1726 
    1727 unsigned int InspectorController::findXHRBreakpoint(const String& url)
    1728 {
    1729     for (HashMap<unsigned int, String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) {
     1729    else if (type == eventListenerNativeBreakpointType)
     1730        m_eventListenerBreakpoints.remove(breakpointId);
     1731    else if (type == domNativeBreakpointType) {
     1732        if (m_domAgent)
     1733            m_domAgent->removeDOMBreakpoint(breakpointId);
     1734    }
     1735}
     1736
     1737String InspectorController::findEventListenerBreakpoint(const String& eventName)
     1738{
     1739    return m_eventListenerBreakpoints.contains(eventName) ? eventName : "";
     1740}
     1741
     1742String InspectorController::findXHRBreakpoint(const String& url)
     1743{
     1744    for (HashMap<String, String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) {
    17301745        if (url.contains(it->second))
    17311746            return it->first;
    17321747    }
    1733     return 0;
    1734 }
    1735 
     1748    return "";
     1749}
    17361750#endif
    17371751
  • trunk/WebCore/inspector/InspectorController.h

    r69300 r69567  
    260260    void resume();
    261261
    262     void setNativeBreakpoint(PassRefPtr<InspectorObject> breakpoint, unsigned int* breakpointId);
    263     void removeNativeBreakpoint(unsigned int breakpointId);
     262    void setNativeBreakpoint(PassRefPtr<InspectorObject> breakpoint, String* breakpointId);
     263    void removeNativeBreakpoint(const String& breakpointId);
    264264#endif
    265265
     
    301301    void enableDebuggerFromFrontend(bool always);
    302302
    303     unsigned int findEventListenerBreakpoint(const String& eventName);
    304     unsigned int findXHRBreakpoint(const String&);
     303    String findEventListenerBreakpoint(const String& eventName);
     304    String findXHRBreakpoint(const String& url);
    305305#endif
    306306#if ENABLE(DATABASE)
     
    392392    OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
    393393
    394     HashMap<unsigned int, String> m_nativeBreakpoints;
    395     HashMap<unsigned int, String> m_eventListenerBreakpoints;
    396     HashMap<String, unsigned int> m_eventNameToBreakpointId;
    397     HashMap<unsigned int, String> m_XHRBreakpoints;
     394    HashMap<String, String> m_nativeBreakpoints;
     395    HashSet<String> m_eventListenerBreakpoints;
     396    HashMap<String, String> m_XHRBreakpoints;
     397
    398398    unsigned int m_lastBreakpointId;
    399399
  • trunk/WebCore/inspector/InspectorDOMAgent.cpp

    r69284 r69567  
    206206    SubtreeModified = 0,
    207207    AttributeModified,
    208     NodeRemoved
     208    NodeRemoved,
     209    DOMBreakpointTypesCount
    209210};
    210211
     
    754755}
    755756
    756 void InspectorDOMAgent::setDOMBreakpoint(long nodeId, long type)
     757String InspectorDOMAgent::setDOMBreakpoint(long nodeId, long type)
    757758{
    758759    Node* node = nodeForId(nodeId);
    759760    if (!node)
    760         return;
     761        return "";
     762
     763    String breakpointId = createBreakpointId(nodeId, type);
     764    if (m_idToBreakpoint.contains(breakpointId))
     765        return "";
     766
     767    m_idToBreakpoint.set(breakpointId, std::make_pair(nodeId, type));
    761768
    762769    uint32_t rootBit = 1 << type;
     
    766773            updateSubtreeBreakpoints(child, rootBit, true);
    767774    }
    768 }
    769 
    770 void InspectorDOMAgent::removeDOMBreakpoint(long nodeId, long type)
    771 {
    772     Node* node = nodeForId(nodeId);
     775
     776    return breakpointId;
     777}
     778
     779void InspectorDOMAgent::removeDOMBreakpoint(const String& breakpointId)
     780{
     781    Breakpoint breakpoint = m_idToBreakpoint.take(breakpointId);
     782
     783    Node* node = nodeForId(breakpoint.first);
    773784    if (!node)
    774785        return;
    775786
    776     uint32_t rootBit = 1 << type;
     787    uint32_t rootBit = 1 << breakpoint.second;
    777788    uint32_t mask = m_breakpoints.get(node) & ~rootBit;
    778789    if (mask)
     
    846857    long breakpointOwnerNodeId = m_documentNodeToIdMap.get(breakpointOwner);
    847858    ASSERT(breakpointOwnerNodeId);
    848 
    849     RefPtr<InspectorObject> breakpoint = InspectorObject::create();
    850     breakpoint->setNumber("nodeId", breakpointOwnerNodeId);
    851     breakpoint->setNumber("type", breakpointType);
    852     description->setObject("breakpoint", breakpoint);
     859    description->setString("breakpointId", createBreakpointId(breakpointOwnerNodeId, breakpointType));
    853860
    854861    return description;
     
    10941101    if (m_breakpoints.size()) {
    10951102        // Remove subtree breakpoints.
    1096         m_breakpoints.remove(node);
     1103        removeBreakpointsForNode(node);
    10971104        Vector<Node*> stack(1, innerFirstChild(node));
    10981105        do {
     
    11011108            if (!node)
    11021109                continue;
    1103             m_breakpoints.remove(node);
     1110            removeBreakpointsForNode(node);
    11041111            stack.append(innerFirstChild(node));
    11051112            stack.append(innerNextSibling(node));
     
    11661173    for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child))
    11671174        updateSubtreeBreakpoints(child, newRootMask, set);
     1175}
     1176
     1177void InspectorDOMAgent::removeBreakpointsForNode(Node* node)
     1178{
     1179    uint32_t mask = m_breakpoints.take(node);
     1180    if (!mask)
     1181        return;
     1182    long nodeId = m_documentNodeToIdMap.get(node);
     1183    if (!nodeId)
     1184        return;
     1185    for (int type = 0; type < DOMBreakpointTypesCount; ++type) {
     1186        if (mask && (1 << type))
     1187            m_idToBreakpoint.remove(createBreakpointId(nodeId, type));
     1188    }
     1189}
     1190
     1191String InspectorDOMAgent::createBreakpointId(long nodeId, long type)
     1192{
     1193    return String::format("dom:%ld:%ld", nodeId, type);
    11681194}
    11691195
  • trunk/WebCore/inspector/InspectorDOMAgent.h

    r69284 r69567  
    121121        void performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously);
    122122        void searchCanceled();
    123         void setDOMBreakpoint(long nodeId, long type);
    124         void removeDOMBreakpoint(long nodeId, long type);
    125123        bool shouldBreakOnNodeInsertion(Node* node, Node* parent, PassRefPtr<InspectorValue>* details);
    126124        bool shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorValue>* details);
     
    162160        String documentURLString(Document* document) const;
    163161
     162        String setDOMBreakpoint(long nodeId, long type);
     163        void removeDOMBreakpoint(const String& breakpointId);
     164
    164165    private:
    165166        void startListening(Document* document);
     
    177178        bool hasBreakpoint(Node* node, long type);
    178179        void updateSubtreeBreakpoints(Node* root, uint32_t rootMask, bool value);
     180        void removeBreakpointsForNode(Node* node);
    179181        PassRefPtr<InspectorValue> descriptionForDOMEvent(Node* target, long breakpointType, bool insertion);
     182        String createBreakpointId(long nodeId, long type);
    180183
    181184        PassRefPtr<InspectorObject> buildObjectForAttributeStyles(Element* element);
     
    233236        Vector<long> m_inspectedNodes;
    234237        HashMap<Node*, uint32_t> m_breakpoints;
     238        typedef pair<long, long> Breakpoint;
     239        HashMap<String, Breakpoint> m_idToBreakpoint;
    235240    };
    236241
  • trunk/WebCore/inspector/InspectorDebuggerAgent.h

    r69014 r69567  
    4949enum DebuggerEventType {
    5050    JavaScriptPauseEventType,
    51     DOMBreakpointDebuggerEventType,
     51    JavaScriptBreakpointEventType,
    5252    NativeBreakpointDebuggerEventType
    5353};
  • trunk/WebCore/inspector/InspectorInstrumentation.cpp

    r69406 r69567  
    7474    PassRefPtr<InspectorValue> eventData;
    7575    if (domAgent->shouldBreakOnNodeInsertion(node, parent, &eventData))
    76         debuggerAgent->breakProgram(DOMBreakpointDebuggerEventType, eventData);
     76        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
    7777#endif
    7878}
     
    9595    PassRefPtr<InspectorValue> eventData;
    9696    if (domAgent->shouldBreakOnNodeRemoval(node, &eventData))
    97         debuggerAgent->breakProgram(DOMBreakpointDebuggerEventType, eventData);
     97        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
    9898#endif
    9999}
     
    116116    PassRefPtr<InspectorValue> eventData;
    117117    if (domAgent->shouldBreakOnAttributeModification(element, &eventData))
    118         debuggerAgent->breakProgram(DOMBreakpointDebuggerEventType, eventData);
     118        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
    119119#endif
    120120}
     
    140140        return;
    141141
    142     unsigned int breakpointId = inspectorController->findXHRBreakpoint(url);
    143     if (!breakpointId)
     142    String breakpointId = inspectorController->findXHRBreakpoint(url);
     143    if (breakpointId.isEmpty())
    144144        return;
    145145
    146146    RefPtr<InspectorObject> eventData = InspectorObject::create();
    147     eventData->setNumber("breakpointId", breakpointId);
    148     eventData->setString("type", "XHR");
     147    eventData->setString("breakpointId", breakpointId);
    149148    eventData->setString("url", url);
    150149    debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
     
    209208#if ENABLE(JAVASCRIPT_DEBUGGER)
    210209    if (InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get()) {
    211         unsigned int breakpointId = inspectorController->findEventListenerBreakpoint(event.type());
    212         if (breakpointId) {
     210        String breakpointId = inspectorController->findEventListenerBreakpoint(event.type());
     211        if (!breakpointId.isEmpty()) {
    213212            RefPtr<InspectorObject> eventData = InspectorObject::create();
    214             eventData->setNumber("breakpointId", breakpointId);
    215             eventData->setString("type", "EventListener");
     213            eventData->setString("breakpointId", breakpointId);
    216214            eventData->setString("eventName", event.type());
    217215            debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData);
  • trunk/WebCore/inspector/front-end/BreakpointManager.js

    r69300 r69567  
    2828{
    2929    this._breakpoints = {};
    30     this._xhrBreakpoints = {};
    31 }
    32 
    33 WebInspector.BreakpointManager.DebuggerEventType = {
    34     JavaScriptPause: 0,
    35     DOMBreakpoint: 1,
    36     NativeBreakpoint: 2
    37 };
     30    this._nativeBreakpoints = {};
     31    this._domBreakpoints = {};
     32}
    3833
    3934WebInspector.BreakpointManager.prototype = {
     
    9489        this._breakpoints = {};
    9590        delete this._oneTimeBreakpoint;
    96         this._xhrBreakpoints = {};
     91        this._nativeBreakpoints = {};
    9792    },
    9893
     
    135130    },
    136131
    137     createEventListenerBreakpoint: function(eventName)
    138     {
    139         var data = { type: "EventListener", condition: { eventName: eventName } };
    140         var breakpoint = new WebInspector.NativeBreakpoint(data, this);
    141         breakpoint.label = eventName;
     132    createDOMBreakpoint: function(nodeId, domEventType, disabled)
     133    {
     134        var frontendId = "dom:" + nodeId + ":" + domEventType;
     135        if (frontendId in this._nativeBreakpoints)
     136            return;
     137
     138        var breakpoint = new WebInspector.DOMBreakpoint(this, frontendId, nodeId, domEventType);
     139        this._nativeBreakpoints[frontendId] = breakpoint;
     140        this._domBreakpoints[frontendId] = breakpoint;
     141        this.dispatchEventToListeners("dom-breakpoint-added", breakpoint);
     142        breakpoint.enabled = !disabled;
    142143        return breakpoint;
    143144    },
    144145
    145     createXHRBreakpoint: function(url)
    146     {
    147         if (url in this._xhrBreakpoints)
    148             return;
    149         this._xhrBreakpoints[url] = true;
    150 
    151         var data = { type: "XHR", condition: { url: url } };
    152         var breakpoint = new WebInspector.NativeBreakpoint(data, this);
    153         if (!url.length)
    154             breakpoint.label = WebInspector.UIString("Any XHR");
    155         else
    156             breakpoint.label = WebInspector.UIString("URL contains \"%s\"", url);
    157         breakpoint.compareTo = function(other)
    158         {
    159             var urlOther = other._data.condition.url;
    160             if (url !== urlOther)
    161                 return url < urlOther ? -1 : 1;
    162             return 0;
    163         };
    164 
    165         breakpoint.addEventListener("removed", this._xhrBreakpointRemoved.bind(this, url));
     146    createEventListenerBreakpoint: function(eventName, disabled)
     147    {
     148        var frontendId = eventName;
     149        if (frontendId in this._nativeBreakpoints)
     150            return;
     151
     152        var breakpoint = new WebInspector.EventListenerBreakpoint(this, frontendId, eventName);
     153        this._nativeBreakpoints[frontendId] = breakpoint;
     154        breakpoint.enabled = !disabled;
     155        return breakpoint;
     156    },
     157
     158    createXHRBreakpoint: function(url, disabled)
     159    {
     160        var frontendId = url;
     161        if (frontendId in this._nativeBreakpoints)
     162            return;
     163
     164        var breakpoint = new WebInspector.XHRBreakpoint(this, frontendId, url);
     165        this._nativeBreakpoints[frontendId] = breakpoint;
    166166        this.dispatchEventToListeners("xhr-breakpoint-added", breakpoint);
    167 
    168         breakpoint.enabled = true;
    169     },
    170 
    171     _xhrBreakpointRemoved: function(url)
    172     {
    173         delete this._xhrBreakpoints[url];
     167        breakpoint.enabled = !disabled
     168        return breakpoint;
    174169    },
    175170
     
    180175        if (breakpoint.enabled)
    181176            this._removeNativeBreakpointFromBackend(breakpoint);
     177        delete this._nativeBreakpoints[breakpoint._frontendId];
     178        if (breakpoint._type === "DOM")
     179            delete this._domBreakpoints[breakpoint._frontendId];
    182180        breakpoint.dispatchEventToListeners("removed");
    183181    },
     
    198196    {
    199197        breakpoint._beingSetOnBackend = true;
    200         InspectorBackend.setNativeBreakpoint(breakpoint._data, didSetNativeBreakpoint.bind(this));
     198        var data = { type: breakpoint._type, condition: breakpoint._condition() };
     199        InspectorBackend.setNativeBreakpoint(data, didSetNativeBreakpoint.bind(this));
    201200
    202201        function didSetNativeBreakpoint(backendBreakpointId)
    203202        {
    204203            breakpoint._beingSetOnBackend = false;
    205             if (backendBreakpointId !== 0) {
     204            if (backendBreakpointId !== "") {
    206205                breakpoint._backendId = backendBreakpointId;
    207206                this._breakpoints[backendBreakpointId] = breakpoint;
     
    221220    debuggerPaused: function(details)
    222221    {
    223         if (details.eventType !== WebInspector.BreakpointManager.DebuggerEventType.NativeBreakpoint)
    224             return;
     222        if (details.eventType !== WebInspector.DebuggerEventTypes.NativeBreakpoint)
     223            return;
     224
    225225        var breakpoint = this._breakpoints[details.eventData.breakpointId];
    226         if (breakpoint) {
    227             breakpoint.hit = true;
    228             breakpoint.dispatchEventToListeners("hit-state-changed");
    229             this._lastHitBreakpoint = breakpoint;
    230         }
     226        if (!breakpoint)
     227            return;
     228
     229        breakpoint.hit = true;
     230        breakpoint.dispatchEventToListeners("hit-state-changed");
     231        this._lastHitBreakpoint = breakpoint;
     232
     233        this.dispatchEventToListeners("breakpoint-hit", { breakpoint: breakpoint, eventData: details.eventData });
    231234    },
    232235
     
    238241        this._lastHitBreakpoint.dispatchEventToListeners("hit-state-changed");
    239242        delete this._lastHitBreakpoint;
     243    },
     244
     245    restoreDOMBreakpoints: function()
     246    {
     247        var domBreakpoints = this._domBreakpoints;
     248        this._domBreakpoints = {};
     249
     250        var breakpointsToRestore = {};
     251        for (var frontendId in domBreakpoints) {
     252            var breakpoint = domBreakpoints[frontendId];
     253            var path = breakpoint._path;
     254            if (!path)
     255                continue;
     256            if (!breakpointsToRestore[path]) {
     257                breakpointsToRestore[path] = [];
     258                InspectorBackend.pushNodeByPathToFrontend(path, restoreBreakpointsForNode.bind(this, breakpointsToRestore[path]));
     259            }
     260            breakpointsToRestore[path].push(breakpoint);
     261        }
     262
     263        function restoreBreakpointsForNode(breakpoints, nodeId)
     264        {
     265            if (!nodeId)
     266                return;
     267            for (var i = 0; i < breakpoints.length; ++i)
     268                this.createDOMBreakpoint(nodeId, breakpoints[i]._domEventType, !breakpoints[i].enabled);
     269        }
    240270    }
    241271}
     
    323353WebInspector.Breakpoint.prototype.__proto__ = WebInspector.Object.prototype;
    324354
    325 WebInspector.NativeBreakpoint = function(data, manager)
    326 {
    327     this._data = data;
     355WebInspector.NativeBreakpoint = function(manager, frontendId, type)
     356{
    328357    this._manager = manager;
     358    this.__frontendId = frontendId;
     359    this.__type = type;
    329360}
    330361
     
    343374    {
    344375        this._manager._removeNativeBreakpoint(this);
     376        this._onRemove();
     377    },
     378
     379    get _frontendId()
     380    {
     381        return this.__frontendId;
     382    },
     383
     384    get _type()
     385    {
     386        return this.__type;
     387    },
     388
     389    _compare: function(x, y)
     390    {
     391        if (x !== y)
     392            return x < y ? -1 : 1;
     393        return 0;
     394    },
     395
     396    _onRemove: function()
     397    {
    345398    }
    346399}
    347400
    348401WebInspector.NativeBreakpoint.prototype.__proto__ = WebInspector.Object.prototype;
     402
     403WebInspector.DOMBreakpoint = function(manager, frontendId, nodeId, domEventType)
     404{
     405    WebInspector.NativeBreakpoint.call(this, manager, frontendId, "DOM");
     406    this._nodeId = nodeId;
     407    this._domEventType = domEventType;
     408
     409    var node = WebInspector.domAgent.nodeForId(this._nodeId);
     410    if (node) {
     411        node.breakpoints[this._domEventType] = this;
     412        this._path = node.path();
     413    }
     414}
     415
     416WebInspector.DOMBreakpoint.prototype = {
     417    click: function()
     418    {
     419        WebInspector.updateFocusedNode(this._nodeId);
     420    },
     421
     422    compareTo: function(other)
     423    {
     424        return this._compare(this._domEventType, other._domEventType);
     425    },
     426
     427    populateLabelElement: function(element)
     428    {
     429        element.appendChild(WebInspector.panels.elements.linkifyNodeById(this._nodeId));
     430        element.appendChild(document.createTextNode(" - "));
     431        element.appendChild(document.createTextNode(WebInspector.domBreakpointTypeLabel(this._domEventType)));
     432    },
     433
     434    populateStatusMessageElement: function(element, eventData)
     435    {
     436        var substitutions = [WebInspector.domBreakpointTypeLabel(this._domEventType), WebInspector.panels.elements.linkifyNodeById(this._nodeId)];
     437        var formatters = {
     438            s: function(substitution)
     439            {
     440                return substitution;
     441            }
     442        };
     443        function append(a, b)
     444        {
     445            if (typeof b === "string")
     446                b = document.createTextNode(b);
     447            element.appendChild(b);
     448        }
     449        if (this._domEventType === WebInspector.DOMBreakpointTypes.SubtreeModified) {
     450            var targetNode = WebInspector.panels.elements.linkifyNodeById(eventData.targetNodeId);
     451            if (eventData.insertion) {
     452                if (eventData.targetNodeId !== this._nodeId)
     453                    WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to its descendant %s.", substitutions.concat(targetNode), formatters, "", append);
     454                else
     455                    WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to that node.", substitutions, formatters, "", append);
     456            } else
     457                WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because its descendant %s was removed.", substitutions.concat(targetNode), formatters, "", append);
     458        } else
     459            WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append);
     460    },
     461
     462    _condition: function()
     463    {
     464        return { nodeId: this._nodeId, type: this._domEventType };
     465    },
     466
     467    _onRemove: function()
     468    {
     469        var node = WebInspector.domAgent.nodeForId(this._nodeId);
     470        if (node)
     471            delete node.breakpoints[this._domEventType];
     472    }
     473}
     474
     475WebInspector.DOMBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
     476
     477WebInspector.EventListenerBreakpoint = function(manager, frontendId, eventName)
     478{
     479    WebInspector.NativeBreakpoint.call(this, manager, frontendId, "EventListener");
     480    this._eventName = eventName;
     481}
     482
     483WebInspector.EventListenerBreakpoint.prototype = {
     484    compareTo: function(other)
     485    {
     486        return this._compare(this._eventName, other._eventName);
     487    },
     488
     489    label: function()
     490    {
     491        return this._eventName;
     492    },
     493
     494    populateStatusMessageElement: function(element, eventData)
     495    {
     496        var status = WebInspector.UIString("Paused on a \"%s\" Event Listener.", this._eventName);
     497        element.appendChild(document.createTextNode(status));
     498    },
     499
     500    _condition: function()
     501    {
     502        return { eventName: this._eventName };
     503    }
     504}
     505
     506WebInspector.EventListenerBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
     507
     508WebInspector.XHRBreakpoint = function(manager, frontendId, url)
     509{
     510    WebInspector.NativeBreakpoint.call(this, manager, frontendId, "XHR");
     511    this._url = url;
     512}
     513
     514WebInspector.XHRBreakpoint.prototype = {
     515    compareTo: function(other)
     516    {
     517        return this._compare(this._url, other._url);
     518    },
     519
     520    populateLabelElement: function(element)
     521    {
     522        var label;
     523        if (!this._url.length)
     524            label = WebInspector.UIString("Any XHR");
     525        else
     526            label = WebInspector.UIString("URL contains \"%s\"", this._url);
     527        element.appendChild(document.createTextNode(label));
     528    },
     529
     530    populateStatusMessageElement: function(element)
     531    {
     532        var status = WebInspector.UIString("Paused on a XMLHttpRequest.");
     533        element.appendChild(document.createTextNode(status));
     534    },
     535
     536    _condition: function()
     537    {
     538        return { url: this._url };
     539    }
     540}
     541
     542WebInspector.XHRBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
     543
     544WebInspector.DebuggerEventTypes = {
     545    JavaScriptPause: 0,
     546    JavaScriptBreakpoint: 1,
     547    NativeBreakpoint: 2
     548};
     549
     550WebInspector.DOMBreakpointTypes = {
     551    SubtreeModified: 0,
     552    AttributeModified: 1,
     553    NodeRemoved: 2
     554};
     555
     556WebInspector.domBreakpointTypeLabel = function(type)
     557{
     558    if (!WebInspector._DOMBreakpointTypeLabels) {
     559        WebInspector._DOMBreakpointTypeLabels = {};
     560        WebInspector._DOMBreakpointTypeLabels[WebInspector.DOMBreakpointTypes.SubtreeModified] = WebInspector.UIString("Subtree Modified");
     561        WebInspector._DOMBreakpointTypeLabels[WebInspector.DOMBreakpointTypes.AttributeModified] = WebInspector.UIString("Attribute Modified");
     562        WebInspector._DOMBreakpointTypeLabels[WebInspector.DOMBreakpointTypes.NodeRemoved] = WebInspector.UIString("Node Removed");
     563    }
     564    return WebInspector._DOMBreakpointTypeLabels[type];
     565}
     566
     567WebInspector.domBreakpointTypeContextMenuLabel = function(type)
     568{
     569    if (!WebInspector._DOMBreakpointTypeContextMenuLabels) {
     570        WebInspector._DOMBreakpointTypeContextMenuLabels = {};
     571        WebInspector._DOMBreakpointTypeContextMenuLabels[WebInspector.DOMBreakpointTypes.SubtreeModified] = WebInspector.UIString("Break on Subtree Modifications");
     572        WebInspector._DOMBreakpointTypeContextMenuLabels[WebInspector.DOMBreakpointTypes.AttributeModified] = WebInspector.UIString("Break on Attributes Modifications");
     573        WebInspector._DOMBreakpointTypeContextMenuLabels[WebInspector.DOMBreakpointTypes.NodeRemoved] = WebInspector.UIString("Break on Node Removal");
     574    }
     575    return WebInspector._DOMBreakpointTypeContextMenuLabels[type];
     576}
  • trunk/WebCore/inspector/front-end/BreakpointsSidebarPane.js

    r69300 r69567  
    146146    this._element.appendChild(checkboxElement);
    147147
    148     if ("label" in this._breakpoint)
    149         this._element.appendChild(document.createTextNode(this._breakpoint.label));
     148    if ("populateLabelElement" in this._breakpoint)
     149        this._breakpoint.populateLabelElement(this._element);
    150150
    151151    this._breakpoint.addEventListener("enable-changed", this._enableChanged, this);
     
    172172    _breakpointClicked: function(event)
    173173    {
     174        if ("click" in this._breakpoint)
     175            this._breakpoint.click();
    174176    },
    175177
     
    229231
    230232WebInspector.JSBreakpointItem.prototype.__proto__ = WebInspector.BreakpointItem.prototype;
    231 
    232 WebInspector.DOMBreakpointItem = function(breakpoint)
    233 {
    234     WebInspector.BreakpointItem.call(this, breakpoint);
    235 
    236     var link = WebInspector.panels.elements.linkifyNodeById(this._breakpoint.nodeId);
    237     this._element.appendChild(link);
    238 
    239     var type = WebInspector.DOMBreakpoint.labelForType(this._breakpoint.type);
    240     var typeElement = document.createTextNode(" - " + type);
    241     this._element.appendChild(typeElement);
    242 }
    243 
    244 WebInspector.DOMBreakpointItem.prototype = {
    245     _breakpointClicked: function()
    246     {
    247         WebInspector.updateFocusedNode(this._breakpoint.nodeId);
    248     }
    249 }
    250 
    251 WebInspector.DOMBreakpointItem.prototype.__proto__ = WebInspector.BreakpointItem.prototype;
    252233
    253234WebInspector.EventListenerBreakpointsSidebarPane = function()
     
    284265                var eventName = eventNames[i];
    285266
    286                 var breakpoint = WebInspector.breakpointManager.createEventListenerBreakpoint(eventName);
    287 
    288                 var eventNameTreeElement = new TreeElement(breakpoint.label);
     267                var breakpoint = WebInspector.breakpointManager.createEventListenerBreakpoint(eventName, true);
     268                if (!breakpoint)
     269                    continue;
     270
     271                var eventNameTreeElement = new TreeElement(breakpoint.label());
    289272                categoryTreeElement.appendChild(eventNameTreeElement);
    290273                eventNameTreeElement.listItemElement.addStyleClass("source-code");
  • trunk/WebCore/inspector/front-end/CallStackSidebarPane.js

    r69300 r69567  
    2727{
    2828    WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack"));
     29    WebInspector.breakpointManager.addEventListener("breakpoint-hit", this._breakpointHit, this);
    2930}
    3031
     
    8182            this.bodyElement.appendChild(placard.element);
    8283        }
    83     },
    84 
    85     updateStatus:  function(eventType, eventData)
    86     {
    87         var statusElement = document.createElement("div");
    88         if (eventType === WebInspector.BreakpointManager.DebuggerEventType.DOMBreakpoint) {
    89             var breakpoint = eventData.breakpoint;
    90             var substitutions = [WebInspector.DOMBreakpoint.labelForType(breakpoint.type), WebInspector.panels.elements.linkifyNodeById(breakpoint.nodeId)];
    91             var formatters = {
    92                 s: function(substitution)
    93                 {
    94                     return substitution;
    95                 }
    96             };
    97             function append(a, b)
    98             {
    99                 if (typeof b === "string")
    100                     b = document.createTextNode(b);
    101                 statusElement.appendChild(b);
    102             }
    103             if (breakpoint.type === WebInspector.DOMBreakpoint.Types.SubtreeModified) {
    104                 var targetNode = WebInspector.panels.elements.linkifyNodeById(eventData.targetNodeId);
    105                 if (eventData.insertion) {
    106                     if (eventData.targetNodeId !== breakpoint.nodeId)
    107                         WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to its descendant %s.", substitutions.concat(targetNode), formatters, "", append);
    108                     else
    109                         WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because a new child was added to that node.", substitutions, formatters, "", append);
    110                 } else
    111                     WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s, because its descendant %s was removed.", substitutions.concat(targetNode), formatters, "", append);
    112             } else
    113                 WebInspector.formatLocalized("Paused on a \"%s\" breakpoint set on %s.", substitutions, formatters, "", append);
    114         } else if (eventType === WebInspector.BreakpointManager.DebuggerEventType.NativeBreakpoint) {
    115             if (eventData.type === "XHR")
    116                 statusElement.appendChild(document.createTextNode(WebInspector.UIString("Paused on a XMLHttpRequest.")));
    117             else if (eventData.type === "EventListener")
    118                 statusElement.appendChild(document.createTextNode(WebInspector.UIString("Paused on a \"%s\" Event Listener.", eventData.eventName)));
    119         } else
    120             return;
    121 
    122         statusElement.className = "info";
    123         this.bodyElement.appendChild(statusElement);
    12484    },
    12585
     
    209169
    210170        section.addRelatedKeys([ nextCallFrame.name, prevCallFrame.name ], WebInspector.UIString("Next/previous call frame"));
     171    },
     172
     173    _breakpointHit:  function(event)
     174    {
     175        var breakpoint = event.data.breakpoint;
     176
     177        var statusMessageElement = document.createElement("div");
     178        statusMessageElement.className = "info";
     179        breakpoint.populateStatusMessageElement(statusMessageElement, event.data.eventData);
     180        this.bodyElement.appendChild(statusMessageElement);
    211181    }
    212182}
  • trunk/WebCore/inspector/front-end/DOMAgent.js

    r68395 r69567  
    6161    this._matchedCSSRules = [];
    6262
     63    this.breakpoints = {};
     64
    6365    if (this.nodeType === Node.ELEMENT_NODE) {
    6466        // HTML and BODY from internal iframes should not overwrite top-level ones.
     
    150152    },
    151153
    152     setBreakpoint: function(type)
    153     {
    154         return WebInspector.domBreakpointManager.setBreakpoint(this.id, type, true, this.path());
    155     },
    156 
    157     hasBreakpoint: function(type)
    158     {
    159         return !!WebInspector.domBreakpointManager.findBreakpoint(this.id, type);
    160     },
    161 
    162     removeBreakpoint: function(type)
    163     {
    164         var breakpoint = WebInspector.domBreakpointManager.findBreakpoint(this.id, type);
    165         if (breakpoint)
    166             breakpoint.remove();
    167     },
    168 
    169     removeBreakpoints: function()
    170     {
    171         WebInspector.domBreakpointManager.removeBreakpointsForNode(this.id);
    172     },
    173 
    174154    _setAttributesPayload: function(attrs)
    175155    {
     
    400380            this._idToDOMNode[payload.id] = this.document;
    401381            this._bindNodes(this.document.children);
    402             WebInspector.domBreakpointManager.restoreBreakpoints();
     382            WebInspector.breakpointManager.restoreDOMBreakpoints();
    403383        } else
    404384            this.document = null;
     
    462442    _removeBreakpoints: function(node)
    463443    {
    464         node.removeBreakpoints();
     444        for (var type in node.breakpoints)
     445            node.breakpoints[type].remove();
    465446        if (!node.children)
    466447            return;
    467448        for (var i = 0; i < node.children.length; ++i)
    468449            this._removeBreakpoints(node.children[i]);
    469      }
     450    }
    470451}
    471452
     
    729710    this.domAgent._childNodeRemoved.apply(this.domAgent, arguments);
    730711}
    731 
    732 WebInspector.DOMBreakpointManager = function()
    733 {
    734     this._breakpoints = {};
    735     this._pathCache = {};
    736 }
    737 
    738 WebInspector.DOMBreakpointManager.prototype = {
    739     setBreakpoint: function(nodeId, type, enabled, path)
    740     {
    741         if (!(nodeId in this._breakpoints))
    742             this._breakpoints[nodeId] = {};
    743         else if (type in this._breakpoints[nodeId])
    744             return;
    745 
    746         var breakpoint = new WebInspector.DOMBreakpoint(nodeId, type, enabled);
    747         this._breakpoints[nodeId][type] = breakpoint;
    748         breakpoint.addEventListener("removed", this._breakpointRemoved, this);
    749 
    750         if (!(nodeId in this._pathCache))
    751             this._pathCache[nodeId] = path;
    752 
    753         this.dispatchEventToListeners("dom-breakpoint-added", breakpoint);
    754     },
    755 
    756     findBreakpoint: function(nodeId, type)
    757     {
    758         var nodeBreakpoints = this._breakpoints[nodeId];
    759         if (nodeBreakpoints && type in nodeBreakpoints)
    760             return nodeBreakpoints[type];
    761     },
    762 
    763     removeBreakpointsForNode: function(nodeId)
    764     {
    765         var nodeBreakpoints = this._breakpoints[nodeId];
    766         for (var type in nodeBreakpoints)
    767             nodeBreakpoints[type].remove();
    768     },
    769 
    770     _breakpointRemoved: function(event)
    771     {
    772         var breakpoint = event.target;
    773 
    774         var nodeBreakpoints = this._breakpoints[breakpoint.nodeId];
    775         delete nodeBreakpoints[breakpoint.type];
    776         for (var type in nodeBreakpoints)
    777             return;
    778 
    779         delete this._breakpoints[breakpoint.nodeId];
    780         delete this._pathCache[breakpoint.nodeId];
    781     },
    782 
    783     restoreBreakpoints: function()
    784     {
    785         var breakpoints = this._breakpoints;
    786         this._breakpoints = {};
    787         var pathCache = this._pathCache;
    788         this._pathCache = {};
    789 
    790         for (var oldNodeId in breakpoints) {
    791             var path = pathCache[oldNodeId];
    792             InspectorBackend.pushNodeByPathToFrontend(path, restoreBreakpointsForNode.bind(this, breakpoints[oldNodeId], path));
    793         }
    794 
    795         function restoreBreakpointsForNode(nodeBreakpoints, path, nodeId)
    796         {
    797             if (!nodeId)
    798                 return;
    799             for (var type in nodeBreakpoints) {
    800                 var breakpoint = nodeBreakpoints[type];
    801                 this.setBreakpoint(nodeId, breakpoint.type, breakpoint.enabled, path);
    802             }
    803         }
    804     }
    805 }
    806 
    807 WebInspector.DOMBreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
    808 
    809 WebInspector.DOMBreakpoint = function(nodeId, type, enabled)
    810 {
    811     this._nodeId = nodeId;
    812     this._type = type;
    813     this._enabled = enabled;
    814 
    815     if (this.enabled)
    816         InspectorBackend.setDOMBreakpoint(this.nodeId, this.type);
    817 }
    818 
    819 WebInspector.DOMBreakpoint.Types = {
    820     SubtreeModified: 0,
    821     AttributeModified: 1,
    822     NodeRemoved: 2
    823 };
    824 
    825 WebInspector.DOMBreakpoint.labelForType = function(type)
    826 {
    827     if (!WebInspector.DOMBreakpoint._labels) {
    828         WebInspector.DOMBreakpoint._labels = {};
    829         WebInspector.DOMBreakpoint._labels[WebInspector.DOMBreakpoint.Types.SubtreeModified] = WebInspector.UIString("Subtree Modified");
    830         WebInspector.DOMBreakpoint._labels[WebInspector.DOMBreakpoint.Types.AttributeModified] = WebInspector.UIString("Attribute Modified");
    831         WebInspector.DOMBreakpoint._labels[WebInspector.DOMBreakpoint.Types.NodeRemoved] = WebInspector.UIString("Node Removed");
    832     }
    833     return WebInspector.DOMBreakpoint._labels[type];
    834 }
    835 
    836 WebInspector.DOMBreakpoint.contextMenuLabelForType = function(type)
    837 {
    838     if (!WebInspector.DOMBreakpoint._contextMenuLabels) {
    839         WebInspector.DOMBreakpoint._contextMenuLabels = {};
    840         WebInspector.DOMBreakpoint._contextMenuLabels[WebInspector.DOMBreakpoint.Types.SubtreeModified] = WebInspector.UIString("Break on Subtree Modifications");
    841         WebInspector.DOMBreakpoint._contextMenuLabels[WebInspector.DOMBreakpoint.Types.AttributeModified] = WebInspector.UIString("Break on Attributes Modifications");
    842         WebInspector.DOMBreakpoint._contextMenuLabels[WebInspector.DOMBreakpoint.Types.NodeRemoved] = WebInspector.UIString("Break on Node Removal");
    843     }
    844     return WebInspector.DOMBreakpoint._contextMenuLabels[type];
    845 }
    846 
    847 WebInspector.DOMBreakpoint.prototype = {
    848     get nodeId()
    849     {
    850         return this._nodeId;
    851     },
    852 
    853     get type()
    854     {
    855         return this._type;
    856     },
    857 
    858     get enabled()
    859     {
    860         return this._enabled;
    861     },
    862 
    863     set enabled(enabled)
    864     {
    865         if (this._enabled === enabled)
    866             return;
    867 
    868         this._enabled = enabled;
    869         if (this.enabled)
    870             InspectorBackend.setDOMBreakpoint(this.nodeId, this.type);
    871         else
    872             InspectorBackend.removeDOMBreakpoint(this.nodeId, this.type);
    873 
    874         this.dispatchEventToListeners("enable-changed");
    875     },
    876 
    877     compareTo: function(other)
    878     {
    879         if (this.type != other.type)
    880             return this.type < other.type ? -1 : 1;
    881         return 0;
    882     },
    883 
    884     remove: function()
    885     {
    886         if (this.enabled)
    887             InspectorBackend.removeDOMBreakpoint(this.nodeId, this.type);
    888         this.dispatchEventToListeners("removed");
    889     }
    890 }
    891 
    892 WebInspector.DOMBreakpoint.prototype.__proto__ = WebInspector.Object.prototype;
    893 
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r68140 r69567  
    760760
    761761            var node = this.representedObject;
    762             for (var key in WebInspector.DOMBreakpoint.Types) {
    763                 var type = WebInspector.DOMBreakpoint.Types[key];
    764                 var label = WebInspector.DOMBreakpoint.contextMenuLabelForType(type);
    765                 var hasBreakpoint = node.hasBreakpoint(type);
    766                 if (!hasBreakpoint)
    767                     var handler = node.setBreakpoint.bind(node, type);
     762            for (var key in WebInspector.DOMBreakpointTypes) {
     763                var type = WebInspector.DOMBreakpointTypes[key];
     764                var label = WebInspector.domBreakpointTypeContextMenuLabel(type);
     765                var breakpoint = node.breakpoints[type];
     766                if (!breakpoint)
     767                    var handler = WebInspector.breakpointManager.createDOMBreakpoint.bind(WebInspector.breakpointManager, node.id, type);
    768768                else
    769                     var handler = node.removeBreakpoint.bind(node, type);
    770                 contextMenu.appendCheckboxItem(label, handler, hasBreakpoint);
     769                    var handler = breakpoint.remove.bind(breakpoint);
     770                contextMenu.appendCheckboxItem(label, handler, !!breakpoint);
    771771            }
    772772        }
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r69203 r69567  
    389389        this.sidebarPanes.callstack.selectedCallFrame = details.callFrames[0];
    390390
    391         if ("eventType" in details)
    392             this.sidebarPanes.callstack.updateStatus(details.eventType, details.eventData);
    393 
    394391        WebInspector.currentPanel = this;
    395392        window.focus();
  • trunk/WebCore/inspector/front-end/inspector.js

    r69300 r69567  
    214214        function breakpointAdded(event)
    215215        {
    216             pane.addBreakpoint(new WebInspector.DOMBreakpointItem(event.data));
    217         }
    218         WebInspector.domBreakpointManager.addEventListener("dom-breakpoint-added", breakpointAdded);
     216            pane.addBreakpoint(new WebInspector.BreakpointItem(event.data));
     217        }
     218        WebInspector.breakpointManager.addEventListener("dom-breakpoint-added", breakpointAdded);
    219219        return pane;
    220220    },
     
    531531
    532532    this.breakpointManager = new WebInspector.BreakpointManager();
    533     this.domBreakpointManager = new WebInspector.DOMBreakpointManager();
    534533    this.cssModel = new WebInspector.CSSStyleModel();
    535534
     
    14601459WebInspector.reset = function()
    14611460{
     1461    this.breakpointManager.reset();
     1462
    14621463    for (var panelName in this.panels) {
    14631464        var panel = this.panels[panelName];
     
    14671468
    14681469    this.sessionSettings.reset();
    1469     this.breakpointManager.reset();
    14701470
    14711471    for (var category in this.resourceCategories)
Note: See TracChangeset for help on using the changeset viewer.