Changeset 73726 in webkit
- Timestamp:
- Dec 10, 2010 7:33:21 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r73723 r73726 1 2010-12-10 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: introduce a pair of set/remove methods for each breakpoint type. 6 https://bugs.webkit.org/show_bug.cgi?id=50809 7 8 * inspector/Inspector.idl: 9 * inspector/InspectorController.cpp: 10 (WebCore::InspectorController::InspectorController): 11 (WebCore::InspectorController::setEventListenerBreakpoint): 12 (WebCore::InspectorController::removeEventListenerBreakpoint): 13 (WebCore::InspectorController::hasEventListenerBreakpoint): 14 (WebCore::InspectorController::setXHRBreakpoint): 15 (WebCore::InspectorController::removeXHRBreakpoint): 16 (WebCore::InspectorController::hasXHRBreakpoint): 17 (WebCore::InspectorController::clearNativeBreakpoints): 18 * inspector/InspectorController.h: 19 * inspector/InspectorDOMAgent.cpp: 20 (WebCore::InspectorDOMAgent::setDOMBreakpoint): 21 (WebCore::InspectorDOMAgent::removeDOMBreakpoint): 22 (WebCore::InspectorDOMAgent::shouldBreakOnNodeInsertion): 23 (WebCore::InspectorDOMAgent::shouldBreakOnNodeRemoval): 24 (WebCore::InspectorDOMAgent::shouldBreakOnAttributeModification): 25 (WebCore::InspectorDOMAgent::descriptionForDOMEvent): 26 (WebCore::InspectorDOMAgent::didRemoveDOMNode): 27 * inspector/InspectorDOMAgent.h: 28 * inspector/InspectorInstrumentation.cpp: 29 (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl): 30 (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl): 31 (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl): 32 (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl): 33 (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded): 34 * inspector/front-end/BreakpointManager.js: 35 (WebInspector.BreakpointManager): 36 (WebInspector.NativeBreakpoint): 37 (WebInspector.DOMBreakpoint): 38 (WebInspector.EventListenerBreakpoint): 39 (WebInspector.XHRBreakpoint): 40 * inspector/front-end/CallStackSidebarPane.js: 41 (WebInspector.CallStackSidebarPane): 42 (WebInspector.CallStackSidebarPane.prototype._nativeBreakpointHit): 43 * inspector/front-end/DebuggerModel.js: 44 (WebInspector.DebuggerModel.prototype.debuggerPaused): 45 1 46 2010-12-10 Adam Roben <aroben@apple.com> 2 47 -
trunk/WebCore/inspector/Inspector.idl
r73607 r73726 146 146 [domain=Debugger] void getScriptSource(in String sourceID, out String scriptSource); 147 147 148 [domain=Inspector] void setNativeBreakpoint(in Object breakpoint, out String breakpointId); 149 [domain=Inspector] void removeNativeBreakpoint(in String breakpointId); 148 [domain=DOM] void setDOMBreakpoint(in long nodeId, in long type); 149 [domain=DOM] void removeDOMBreakpoint(in long nodeId, in long type); 150 [domain=Inspector] void setEventListenerBreakpoint(in String eventName); 151 [domain=Inspector] void removeEventListenerBreakpoint(in String eventName); 152 [domain=Inspector] void setXHRBreakpoint(in String url); 153 [domain=Inspector] void removeXHRBreakpoint(in String url); 150 154 151 155 [domain=Inspector] void enableProfiler(in boolean always); -
trunk/WebCore/inspector/InspectorController.cpp
r73607 r73726 125 125 namespace WebCore { 126 126 127 static const char* const domNativeBreakpointType = "DOM";128 static const char* const eventListenerNativeBreakpointType = "EventListener";129 static const char* const xhrNativeBreakpointType = "XHR";130 131 127 const char* const InspectorController::ElementsPanel = "elements"; 132 128 const char* const InspectorController::ConsolePanel = "console"; … … 153 149 #if ENABLE(JAVASCRIPT_DEBUGGER) 154 150 , m_attachDebuggerWhenShown(false) 155 , m_ lastBreakpointId(0)151 , m_hasXHRBreakpointWithEmptyURL(false) 156 152 , m_profilerAgent(InspectorProfilerAgent::create(this)) 157 153 #endif … … 1387 1383 } 1388 1384 1389 void InspectorController::setNativeBreakpoint(PassRefPtr<InspectorObject> breakpoint, String* breakpointId) 1390 { 1391 *breakpointId = ""; 1392 String type; 1393 if (!breakpoint->getString("type", &type)) 1394 return; 1395 RefPtr<InspectorObject> condition = breakpoint->getObject("condition"); 1396 if (!condition) 1397 return; 1398 if (type == xhrNativeBreakpointType) { 1399 String url; 1400 if (!condition->getString("url", &url)) 1401 return; 1402 *breakpointId = String::number(++m_lastBreakpointId); 1403 m_XHRBreakpoints.set(*breakpointId, url); 1404 m_nativeBreakpoints.set(*breakpointId, type); 1405 } else if (type == eventListenerNativeBreakpointType) { 1406 String eventName; 1407 if (!condition->getString("eventName", &eventName)) 1408 return; 1409 if (m_eventListenerBreakpoints.contains(eventName)) 1410 return; 1411 *breakpointId = eventName; 1412 m_eventListenerBreakpoints.add(eventName); 1413 m_nativeBreakpoints.set(*breakpointId, type); 1414 } else if (type == domNativeBreakpointType) { 1415 if (!m_domAgent) 1416 return; 1417 double nodeIdNumber; 1418 if (!condition->getNumber("nodeId", &nodeIdNumber)) 1419 return; 1420 double domBreakpointTypeNumber; 1421 if (!condition->getNumber("type", &domBreakpointTypeNumber)) 1422 return; 1423 long nodeId = (long) nodeIdNumber; 1424 long domBreakpointType = (long) domBreakpointTypeNumber; 1425 *breakpointId = m_domAgent->setDOMBreakpoint(nodeId, domBreakpointType); 1426 if (!breakpointId->isEmpty()) 1427 m_nativeBreakpoints.set(*breakpointId, type); 1428 } 1429 } 1430 1431 void InspectorController::removeNativeBreakpoint(const String& breakpointId) 1432 { 1433 String type = m_nativeBreakpoints.take(breakpointId); 1434 if (type == xhrNativeBreakpointType) 1435 m_XHRBreakpoints.remove(breakpointId); 1436 else if (type == eventListenerNativeBreakpointType) 1437 m_eventListenerBreakpoints.remove(breakpointId); 1438 else if (type == domNativeBreakpointType) { 1439 if (m_domAgent) 1440 m_domAgent->removeDOMBreakpoint(breakpointId); 1441 } 1442 } 1443 1444 String InspectorController::findEventListenerBreakpoint(const String& eventName) 1445 { 1446 return m_eventListenerBreakpoints.contains(eventName) ? eventName : ""; 1447 } 1448 1449 String InspectorController::findXHRBreakpoint(const String& url) 1450 { 1451 for (HashMap<String, String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) { 1452 if (url.contains(it->second)) 1453 return it->first; 1454 } 1455 return ""; 1385 void InspectorController::setEventListenerBreakpoint(const String& eventName) 1386 { 1387 m_eventListenerBreakpoints.add(eventName); 1388 } 1389 1390 void InspectorController::removeEventListenerBreakpoint(const String& eventName) 1391 { 1392 m_eventListenerBreakpoints.remove(eventName); 1393 } 1394 1395 bool InspectorController::hasEventListenerBreakpoint(const String& eventName) 1396 { 1397 return m_eventListenerBreakpoints.contains(eventName); 1398 } 1399 1400 void InspectorController::setXHRBreakpoint(const String& url) 1401 { 1402 if (url.isEmpty()) 1403 m_hasXHRBreakpointWithEmptyURL = true; 1404 else 1405 m_XHRBreakpoints.add(url); 1406 } 1407 1408 void InspectorController::removeXHRBreakpoint(const String& url) 1409 { 1410 if (url.isEmpty()) 1411 m_hasXHRBreakpointWithEmptyURL = false; 1412 else 1413 m_XHRBreakpoints.remove(url); 1414 } 1415 1416 bool InspectorController::hasXHRBreakpoint(const String& url, String* breakpointURL) 1417 { 1418 if (m_hasXHRBreakpointWithEmptyURL) { 1419 *breakpointURL = ""; 1420 return true; 1421 } 1422 for (HashSet<String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) { 1423 if (url.contains(*it)) { 1424 *breakpointURL = *it; 1425 return true; 1426 } 1427 } 1428 return false; 1456 1429 } 1457 1430 1458 1431 void InspectorController::clearNativeBreakpoints() 1459 1432 { 1460 m_nativeBreakpoints.clear();1461 1433 m_eventListenerBreakpoints.clear(); 1462 1434 m_XHRBreakpoints.clear(); 1463 m_ lastBreakpointId = 0;1435 m_hasXHRBreakpointWithEmptyURL = false; 1464 1436 } 1465 1437 #endif -
trunk/WebCore/inspector/InspectorController.h
r73504 r73726 256 256 void resume(); 257 257 258 void setNativeBreakpoint(PassRefPtr<InspectorObject> breakpoint, String* breakpointId); 259 void removeNativeBreakpoint(const String& breakpointId); 258 void setEventListenerBreakpoint(const String& eventName); 259 void removeEventListenerBreakpoint(const String& eventName); 260 bool hasEventListenerBreakpoint(const String& eventName); 261 void setXHRBreakpoint(const String& url); 262 void removeXHRBreakpoint(const String& url); 263 bool hasXHRBreakpoint(const String& url, String* breakpointURL); 260 264 #endif 261 265 … … 307 311 void enableDebuggerFromFrontend(bool always); 308 312 309 String findEventListenerBreakpoint(const String& eventName);310 String findXHRBreakpoint(const String& url);311 313 void clearNativeBreakpoints(); 312 314 #endif … … 387 389 OwnPtr<InspectorDebuggerAgent> m_debuggerAgent; 388 390 389 HashMap<String, String> m_nativeBreakpoints;390 391 HashSet<String> m_eventListenerBreakpoints; 391 HashMap<String, String> m_XHRBreakpoints; 392 393 unsigned int m_lastBreakpointId; 392 HashSet<String> m_XHRBreakpoints; 393 bool m_hasXHRBreakpointWithEmptyURL; 394 394 395 395 OwnPtr<InspectorProfilerAgent> m_profilerAgent; -
trunk/WebCore/inspector/InspectorDOMAgent.cpp
r73121 r73726 761 761 } 762 762 763 StringInspectorDOMAgent::setDOMBreakpoint(long nodeId, long type)763 void InspectorDOMAgent::setDOMBreakpoint(long nodeId, long type) 764 764 { 765 765 Node* node = nodeForId(nodeId); 766 766 if (!node) 767 return ""; 768 769 String breakpointId = createBreakpointId(nodeId, type); 770 if (m_idToBreakpoint.contains(breakpointId)) 771 return ""; 772 773 m_idToBreakpoint.set(breakpointId, std::make_pair(nodeId, type)); 767 return; 774 768 775 769 uint32_t rootBit = 1 << type; … … 779 773 updateSubtreeBreakpoints(child, rootBit, true); 780 774 } 781 782 return breakpointId; 783 } 784 785 void InspectorDOMAgent::removeDOMBreakpoint(const String& breakpointId) 786 { 787 Breakpoint breakpoint = m_idToBreakpoint.take(breakpointId); 788 789 Node* node = nodeForId(breakpoint.first); 775 } 776 777 void InspectorDOMAgent::removeDOMBreakpoint(long nodeId, long type) 778 { 779 Node* node = nodeForId(nodeId); 790 780 if (!node) 791 781 return; 792 782 793 uint32_t rootBit = 1 << breakpoint.second;783 uint32_t rootBit = 1 << type; 794 784 uint32_t mask = m_breakpoints.get(node) & ~rootBit; 795 785 if (mask) … … 804 794 } 805 795 806 bool InspectorDOMAgent::shouldBreakOnNodeInsertion(Node*, Node* parent, PassRefPtr<Inspector Value>*details)796 bool InspectorDOMAgent::shouldBreakOnNodeInsertion(Node*, Node* parent, PassRefPtr<InspectorObject> details) 807 797 { 808 798 if (hasBreakpoint(parent, SubtreeModified)) { 809 *details = descriptionForDOMEvent(parent, SubtreeModified, true);799 descriptionForDOMEvent(parent, SubtreeModified, true, details); 810 800 return true; 811 801 } … … 813 803 } 814 804 815 bool InspectorDOMAgent::shouldBreakOnNodeRemoval(Node* node, PassRefPtr<Inspector Value>*details)805 bool InspectorDOMAgent::shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorObject> details) 816 806 { 817 807 if (hasBreakpoint(node, NodeRemoved)) { 818 *details = descriptionForDOMEvent(node, NodeRemoved, false);808 descriptionForDOMEvent(node, NodeRemoved, false, details); 819 809 return true; 820 810 } 821 811 if (hasBreakpoint(innerParentNode(node), SubtreeModified)) { 822 *details = descriptionForDOMEvent(node, SubtreeModified, false);812 descriptionForDOMEvent(node, SubtreeModified, false, details); 823 813 return true; 824 814 } … … 826 816 } 827 817 828 bool InspectorDOMAgent::shouldBreakOnAttributeModification(Element* element, PassRefPtr<Inspector Value>*details)818 bool InspectorDOMAgent::shouldBreakOnAttributeModification(Element* element, PassRefPtr<InspectorObject> details) 829 819 { 830 820 if (hasBreakpoint(element, AttributeModified)) { 831 *details = descriptionForDOMEvent(element, AttributeModified, false);821 descriptionForDOMEvent(element, AttributeModified, false, details); 832 822 return true; 833 823 } … … 835 825 } 836 826 837 PassRefPtr<InspectorValue> InspectorDOMAgent::descriptionForDOMEvent(Node* target, long breakpointType, bool insertion)827 void InspectorDOMAgent::descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, PassRefPtr<InspectorObject> description) 838 828 { 839 829 ASSERT(hasBreakpoint(target, breakpointType)); 840 830 841 RefPtr<InspectorObject> description = InspectorObject::create();842 831 Node* breakpointOwner = target; 843 832 if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) { … … 863 852 long breakpointOwnerNodeId = m_documentNodeToIdMap.get(breakpointOwner); 864 853 ASSERT(breakpointOwnerNodeId); 865 description->setString("breakpointId", createBreakpointId(breakpointOwnerNodeId, breakpointType)); 866 867 return description; 854 description->setNumber("nodeId", breakpointOwnerNodeId); 855 description->setNumber("type", breakpointType); 868 856 } 869 857 … … 1107 1095 if (m_breakpoints.size()) { 1108 1096 // Remove subtree breakpoints. 1109 removeBreakpointsForNode(node);1097 m_breakpoints.remove(node); 1110 1098 Vector<Node*> stack(1, innerFirstChild(node)); 1111 1099 do { … … 1114 1102 if (!node) 1115 1103 continue; 1116 removeBreakpointsForNode(node);1104 m_breakpoints.remove(node); 1117 1105 stack.append(innerFirstChild(node)); 1118 1106 stack.append(innerNextSibling(node)); … … 1179 1167 for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child)) 1180 1168 updateSubtreeBreakpoints(child, newRootMask, set); 1181 }1182 1183 void InspectorDOMAgent::removeBreakpointsForNode(Node* node)1184 {1185 uint32_t mask = m_breakpoints.take(node);1186 if (!mask)1187 return;1188 long nodeId = m_documentNodeToIdMap.get(node);1189 if (!nodeId)1190 return;1191 for (int type = 0; type < DOMBreakpointTypesCount; ++type) {1192 if (mask && (1 << type))1193 m_idToBreakpoint.remove(createBreakpointId(nodeId, type));1194 }1195 }1196 1197 String InspectorDOMAgent::createBreakpointId(long nodeId, long type)1198 {1199 return makeString("dom:", String::number(nodeId), ':', String::number(type));1200 1169 } 1201 1170 -
trunk/WebCore/inspector/InspectorDOMAgent.h
r73121 r73726 120 120 void performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously); 121 121 void searchCanceled(); 122 bool shouldBreakOnNodeInsertion(Node* node, Node* parent, PassRefPtr<Inspector Value>*details);123 bool shouldBreakOnNodeRemoval(Node* node, PassRefPtr<Inspector Value>*details);124 bool shouldBreakOnAttributeModification(Element* element, PassRefPtr<Inspector Value>*details);122 bool shouldBreakOnNodeInsertion(Node* node, Node* parent, PassRefPtr<InspectorObject> details); 123 bool shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorObject> details); 124 bool shouldBreakOnAttributeModification(Element* element, PassRefPtr<InspectorObject> details); 125 125 126 126 // Methods called from the InspectorController. … … 144 144 String documentURLString(Document* document) const; 145 145 146 StringsetDOMBreakpoint(long nodeId, long type);147 void removeDOMBreakpoint( const String& breakpointId);146 void setDOMBreakpoint(long nodeId, long type); 147 void removeDOMBreakpoint(long nodeId, long type); 148 148 149 149 private: … … 162 162 bool hasBreakpoint(Node* node, long type); 163 163 void updateSubtreeBreakpoints(Node* root, uint32_t rootMask, bool value); 164 void removeBreakpointsForNode(Node* node); 165 PassRefPtr<InspectorValue> descriptionForDOMEvent(Node* target, long breakpointType, bool insertion); 166 String createBreakpointId(long nodeId, long type); 164 void descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, PassRefPtr<InspectorObject> description); 167 165 168 166 PassRefPtr<InspectorObject> buildObjectForNode(Node* node, int depth, NodeToIdMap* nodesMap); … … 205 203 Vector<long> m_inspectedNodes; 206 204 HashMap<Node*, uint32_t> m_breakpoints; 207 typedef pair<long, long> Breakpoint;208 HashMap<String, Breakpoint> m_idToBreakpoint;209 205 }; 210 206 -
trunk/WebCore/inspector/InspectorInstrumentation.cpp
r71934 r73726 46 46 namespace WebCore { 47 47 48 static const char* const domNativeBreakpointType = "DOM"; 49 static const char* const eventListenerNativeBreakpointType = "EventListener"; 50 static const char* const xhrNativeBreakpointType = "XHR"; 51 48 52 static const char* const listenerEventCategoryType = "listener"; 49 53 static const char* const instrumentationEventCategoryType = "instrumentation"; … … 81 85 if (!domAgent) 82 86 return; 83 PassRefPtr<InspectorValue> eventData; 84 if (domAgent->shouldBreakOnNodeInsertion(node, parent, &eventData)) 87 RefPtr<InspectorObject> eventData = InspectorObject::create(); 88 if (domAgent->shouldBreakOnNodeInsertion(node, parent, eventData)) { 89 eventData->setString("breakpointType", domNativeBreakpointType); 85 90 debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); 91 } 86 92 #endif 87 93 } … … 102 108 if (!domAgent) 103 109 return; 104 PassRefPtr<InspectorValue> eventData; 105 if (domAgent->shouldBreakOnNodeRemoval(node, &eventData)) 110 RefPtr<InspectorObject> eventData = InspectorObject::create(); 111 if (domAgent->shouldBreakOnNodeRemoval(node, eventData)) { 112 eventData->setString("breakpointType", domNativeBreakpointType); 106 113 debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); 114 } 107 115 #endif 108 116 } … … 123 131 if (!domAgent) 124 132 return; 125 PassRefPtr<InspectorValue> eventData; 126 if (domAgent->shouldBreakOnAttributeModification(element, &eventData)) 133 RefPtr<InspectorObject> eventData = InspectorObject::create(); 134 if (domAgent->shouldBreakOnAttributeModification(element, eventData)) { 135 eventData->setString("breakpointType", domNativeBreakpointType); 127 136 debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); 137 } 128 138 #endif 129 139 } … … 148 158 return; 149 159 150 String breakpoint Id = inspectorController->findXHRBreakpoint(url);151 if ( breakpointId.isEmpty())160 String breakpointURL; 161 if (!inspectorController->hasXHRBreakpoint(url, &breakpointURL)) 152 162 return; 153 163 154 164 RefPtr<InspectorObject> eventData = InspectorObject::create(); 155 eventData->setString("breakpointId", breakpointId); 165 eventData->setString("breakpointType", xhrNativeBreakpointType); 166 eventData->setString("breakpointURL", breakpointURL); 156 167 eventData->setString("url", url); 157 168 debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); … … 447 458 return; 448 459 String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data()); 449 String breakpointId = inspectorController->findEventListenerBreakpoint(fullEventName); 450 if (breakpointId.isEmpty()) 460 if (!inspectorController->hasEventListenerBreakpoint(fullEventName)) 451 461 return; 452 462 RefPtr<InspectorObject> eventData = InspectorObject::create(); 453 eventData->setString("breakpointId", breakpointId); 463 eventData->setString("breakpointType", eventListenerNativeBreakpointType); 464 eventData->setString("eventName", fullEventName); 454 465 if (synchronous) 455 466 debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData); -
trunk/WebCore/inspector/front-end/BreakpointManager.js
r73501 r73726 32 32 { 33 33 this._nativeBreakpoints = {}; 34 this._backendIdToBreakpoint = {};35 34 36 35 WebInspector.debuggerModel.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this); … … 38 37 } 39 38 39 WebInspector.BreakpointManager.NativeBreakpointTypes = { 40 DOM: "DOM", 41 EventListener: "EventListener", 42 XHR: "XHR" 43 } 44 40 45 WebInspector.BreakpointManager.prototype = { 41 createDOMBreakpoint: function(nodeId, domEventType, disabled)42 { 43 var frontendId = "dom:" + nodeId + ":" + domEventType;44 if ( frontendId in this._nativeBreakpoints)46 createDOMBreakpoint: function(nodeId, type, disabled) 47 { 48 var node = WebInspector.domAgent.nodeForId(nodeId); 49 if (!node) 45 50 return; 46 51 47 var breakpoint = new WebInspector.DOMBreakpoint(this, frontendId, nodeId, domEventType); 48 this._nativeBreakpoints[frontendId] = breakpoint; 52 var breakpointId = this._createDOMBreakpointId(nodeId, type); 53 if (breakpointId in this._nativeBreakpoints) 54 return; 55 56 var breakpoint = new WebInspector.DOMBreakpoint(this, breakpointId, !disabled, node, type); 57 this._nativeBreakpoints[breakpointId] = breakpoint; 58 this._updateNativeBreakpointsInSettings(); 49 59 this.dispatchEventToListeners("dom-breakpoint-added", breakpoint); 50 breakpoint.enabled = !disabled;51 60 return breakpoint; 52 61 }, … … 54 63 createEventListenerBreakpoint: function(eventName) 55 64 { 56 var frontendId = eventName;57 if ( frontendId in this._nativeBreakpoints)65 var breakpointId = this._createEventListenerBreakpointId(eventName); 66 if (breakpointId in this._nativeBreakpoints) 58 67 return; 59 68 60 var breakpoint = new WebInspector.EventListenerBreakpoint(this, frontendId, eventName); 61 this._nativeBreakpoints[frontendId] = breakpoint; 69 var breakpoint = new WebInspector.EventListenerBreakpoint(this, breakpointId, true, eventName); 70 this._nativeBreakpoints[breakpointId] = breakpoint; 71 this._updateNativeBreakpointsInSettings(); 62 72 this.dispatchEventToListeners("event-listener-breakpoint-added", { breakpoint: breakpoint, eventName: eventName }); 63 breakpoint.enabled = true;64 73 return breakpoint; 65 74 }, … … 67 76 createXHRBreakpoint: function(url, disabled) 68 77 { 69 var frontendId = url;70 if ( frontendId in this._nativeBreakpoints)78 var breakpointId = this._createXHRBreakpointId(url); 79 if (breakpointId in this._nativeBreakpoints) 71 80 return; 72 81 73 var breakpoint = new WebInspector.XHRBreakpoint(this, frontendId, url); 74 this._nativeBreakpoints[frontendId] = breakpoint; 82 var breakpoint = new WebInspector.XHRBreakpoint(this, breakpointId, !disabled, url); 83 this._nativeBreakpoints[breakpointId] = breakpoint; 84 this._updateNativeBreakpointsInSettings(); 75 85 this.dispatchEventToListeners("xhr-breakpoint-added", breakpoint); 76 breakpoint.enabled = !disabled77 86 return breakpoint; 78 87 }, 79 88 80 findBreakpoint: function(backendBreakpointId) 81 { 82 return this._backendIdToBreakpoint[backendBreakpointId]; 83 }, 84 85 _removeNativeBreakpoint: function(breakpoint) 86 { 87 if (breakpoint._beingSetOnBackend) 88 return; 89 _setNativeBreakpointEnabled: function(breakpointId, enabled) 90 { 91 var breakpoint = this._nativeBreakpoints[breakpointId]; 92 93 if (enabled) 94 breakpoint._enable(); 95 else 96 breakpoint._disable(); 97 98 breakpoint._enabled = enabled; 99 this._updateNativeBreakpointsInSettings(); 100 breakpoint.dispatchEventToListeners("enable-changed"); 101 }, 102 103 _removeNativeBreakpoint: function(breakpointId) 104 { 105 var breakpoint = this._nativeBreakpoints[breakpointId]; 106 89 107 if (breakpoint.enabled) 90 this._removeNativeBreakpointFromBackend(breakpoint); 91 delete this._nativeBreakpoints[breakpoint._frontendId]; 108 breakpoint._disable(); 109 110 delete this._nativeBreakpoints[breakpointId]; 92 111 this._updateNativeBreakpointsInSettings(); 93 112 breakpoint.dispatchEventToListeners("removed"); 94 113 }, 95 114 96 _setNativeBreakpointEnabled: function(breakpoint, enabled)97 {98 if (breakpoint._beingSetOnBackend)99 return;100 if (breakpoint.enabled === enabled)101 return;102 if (enabled)103 this._setNativeBreakpointOnBackend(breakpoint);104 else105 this._removeNativeBreakpointFromBackend(breakpoint);106 },107 108 _setNativeBreakpointOnBackend: function(breakpoint)109 {110 breakpoint._beingSetOnBackend = true;111 var data = { type: breakpoint._type, condition: breakpoint._condition };112 InspectorBackend.setNativeBreakpoint(data, didSetNativeBreakpoint.bind(this));113 114 function didSetNativeBreakpoint(backendBreakpointId)115 {116 breakpoint._beingSetOnBackend = false;117 if (backendBreakpointId !== "") {118 breakpoint._backendId = backendBreakpointId;119 this._backendIdToBreakpoint[backendBreakpointId] = breakpoint;120 }121 breakpoint.dispatchEventToListeners("enable-changed");122 this._updateNativeBreakpointsInSettings();123 }124 },125 126 _removeNativeBreakpointFromBackend: function(breakpoint)127 {128 InspectorBackend.removeNativeBreakpoint(breakpoint._backendId);129 delete this._backendIdToBreakpoint[breakpoint._backendId]130 delete breakpoint._backendId;131 breakpoint.dispatchEventToListeners("enable-changed");132 this._updateNativeBreakpointsInSettings();133 },134 135 115 _updateNativeBreakpointsInSettings: function() 136 116 { 137 var persistentBreakpoints = [];117 var breakpoints = []; 138 118 for (var id in this._nativeBreakpoints) { 139 119 var breakpoint = this._nativeBreakpoints[id]; 140 if (breakpoint._persistentCondition) 141 persistentBreakpoints.push({ type: breakpoint._type, enabled: breakpoint.enabled, condition: breakpoint._persistentCondition }); 120 breakpoints.push(breakpoint._serializeToJSON()); 142 121 } 143 WebInspector.settings.nativeBreakpoints = persistentBreakpoints;122 WebInspector.settings.nativeBreakpoints = breakpoints; 144 123 }, 145 124 146 125 _nativeBreakpointHit: function(event) 147 126 { 148 var breakpointId = event.data.breakpointId; 149 150 var breakpoint = this._backendIdToBreakpoint[breakpointId]; 127 var eventData = event.data; 128 129 var breakpointId; 130 if (eventData.breakpointType === WebInspector.BreakpointManager.NativeBreakpointTypes.DOM) 131 breakpointId = this._createDOMBreakpointId(eventData.nodeId, eventData.type); 132 else if (eventData.breakpointType === WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener) 133 breakpointId = this._createEventListenerBreakpointId(eventData.eventName); 134 else if (eventData.breakpointType === WebInspector.BreakpointManager.NativeBreakpointTypes.XHR) 135 breakpointId = this._createXHRBreakpointId(eventData.breakpointURL); 136 137 var breakpoint = this._nativeBreakpoints[breakpointId]; 151 138 if (!breakpoint) 152 139 return; 153 140 154 141 breakpoint.hit = true; 155 breakpoint.dispatchEventToListeners("hit-state-changed");156 142 this._lastHitBreakpoint = breakpoint; 143 this.dispatchEventToListeners("native-breakpoint-hit", { breakpoint: breakpoint, eventData: eventData }); 157 144 }, 158 145 … … 162 149 return; 163 150 this._lastHitBreakpoint.hit = false; 164 this._lastHitBreakpoint.dispatchEventToListeners("hit-state-changed");165 151 delete this._lastHitBreakpoint; 166 152 }, … … 169 155 { 170 156 var breakpoints = this._persistentBreakpoints(); 157 this._domBreakpoints = []; 171 158 for (var i = 0; i < breakpoints.length; ++i) { 172 if (breakpoints[i].type === "EventListener") 159 if (breakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.DOM) 160 this._domBreakpoints.push(breakpoints[i]); 161 else if (breakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener) 173 162 this.createEventListenerBreakpoint(breakpoints[i].condition.eventName); 174 else if (breakpoints[i].type === "XHR")163 else if (breakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.XHR) 175 164 this.createXHRBreakpoint(breakpoints[i].condition.url, !breakpoints[i].enabled); 176 165 } … … 186 175 return; 187 176 for (var i = 0; i < breakpoints.length; ++i) { 177 if (breakpoints[i].type !== WebInspector.BreakpointManager.NativeBreakpointTypes.DOM) 178 continue; 188 179 var breakpoint = breakpoints[i]; 189 180 var nodeId = pathToNodeId[breakpoint.condition.path]; … … 193 184 } 194 185 195 var breakpoints = this._ persistentBreakpoints();186 var breakpoints = this._domBreakpoints; 196 187 var pathToNodeId = {}; 197 188 var pendingCalls = 0; 198 189 for (var i = 0; i < breakpoints.length; ++i) { 199 if (breakpoints[i].type !== "DOM")190 if (breakpoints[i].type !== WebInspector.BreakpointManager.NativeBreakpointTypes.DOM) 200 191 continue; 201 192 var path = breakpoints[i].condition.path; … … 222 213 }, 223 214 215 _createDOMBreakpointId: function(nodeId, type) 216 { 217 return "dom:" + nodeId + ":" + type; 218 }, 219 220 _createEventListenerBreakpointId: function(eventName) 221 { 222 return "eventListner:" + eventName; 223 }, 224 225 _createXHRBreakpointId: function(url) 226 { 227 return "xhr:" + url; 228 }, 229 224 230 reset: function() 225 231 { 226 232 this._nativeBreakpoints = {}; 227 this._backendIdToBreakpoint = {};228 233 } 229 234 } … … 231 236 WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype; 232 237 233 WebInspector.NativeBreakpoint = function(manager, frontendId, type)238 WebInspector.NativeBreakpoint = function(manager, id, enabled) 234 239 { 235 240 this._manager = manager; 236 this.__frontendId = frontendId; 237 this.__type = type; 241 this._id = id; 242 this._enabled = enabled; 243 this._hit = false; 238 244 } 239 245 … … 241 247 get enabled() 242 248 { 243 return "_backendId" in this;249 return this._enabled; 244 250 }, 245 251 246 252 set enabled(enabled) 247 253 { 248 this._manager._setNativeBreakpointEnabled(this, enabled); 254 this._manager._setNativeBreakpointEnabled(this._id, enabled); 255 }, 256 257 get hit() 258 { 259 return this._hit; 260 }, 261 262 set hit(hit) 263 { 264 this._hit = hit; 265 this.dispatchEventToListeners("hit-state-changed"); 249 266 }, 250 267 251 268 remove: function() 252 269 { 253 this._manager._removeNativeBreakpoint(this );270 this._manager._removeNativeBreakpoint(this._id); 254 271 this._onRemove(); 255 },256 257 get _frontendId()258 {259 return this.__frontendId;260 },261 262 get _type()263 {264 return this.__type;265 272 }, 266 273 … … 279 286 WebInspector.NativeBreakpoint.prototype.__proto__ = WebInspector.Object.prototype; 280 287 281 WebInspector.DOMBreakpoint = function(manager, frontendId, nodeId, domEventType) 282 { 283 WebInspector.NativeBreakpoint.call(this, manager, frontendId, "DOM"); 284 this._nodeId = nodeId; 285 this._domEventType = domEventType; 286 this._condition = { nodeId: this._nodeId, type: this._domEventType }; 287 288 var node = WebInspector.domAgent.nodeForId(this._nodeId); 289 if (node) { 290 node.breakpoints[this._domEventType] = this; 291 this._persistentCondition = { path: node.path(), type: this._domEventType }; 292 } 288 WebInspector.DOMBreakpoint = function(manager, id, enabled, node, type) 289 { 290 WebInspector.NativeBreakpoint.call(this, manager, id, enabled); 291 this._node = node; 292 this._nodeId = node.id; 293 this._path = node.path(); 294 this._type = type; 295 if (enabled) 296 this._enable(); 297 298 node.breakpoints[this._type] = this; 293 299 } 294 300 … … 296 302 compareTo: function(other) 297 303 { 298 return this._compare(this._ domEventType, other._domEventType);304 return this._compare(this._type, other._type); 299 305 }, 300 306 … … 307 313 var description = document.createElement("div"); 308 314 description.className = "source-text"; 309 description.textContent = WebInspector.domBreakpointTypeLabel(this._ domEventType);315 description.textContent = WebInspector.domBreakpointTypeLabel(this._type); 310 316 element.appendChild(description); 311 317 }, … … 313 319 populateStatusMessageElement: function(element, eventData) 314 320 { 315 var substitutions = [WebInspector.domBreakpointTypeLabel(this._ domEventType), WebInspector.panels.elements.linkifyNodeById(this._nodeId)];321 var substitutions = [WebInspector.domBreakpointTypeLabel(this._type), WebInspector.panels.elements.linkifyNodeById(this._nodeId)]; 316 322 var formatters = { 317 323 s: function(substitution) … … 326 332 element.appendChild(b); 327 333 } 328 if (this._ domEventType === WebInspector.DOMBreakpointTypes.SubtreeModified) {334 if (this._type === WebInspector.DOMBreakpointTypes.SubtreeModified) { 329 335 var targetNode = WebInspector.panels.elements.linkifyNodeById(eventData.targetNodeId); 330 336 if (eventData.insertion) { … … 339 345 }, 340 346 347 _enable: function() 348 { 349 InspectorBackend.setDOMBreakpoint(this._nodeId, this._type); 350 }, 351 352 _disable: function() 353 { 354 InspectorBackend.removeDOMBreakpoint(this._nodeId, this._type); 355 }, 356 357 _serializeToJSON: function() 358 { 359 var type = WebInspector.BreakpointManager.NativeBreakpointTypes.DOM; 360 return { type: type, enabled: this._enabled, condition: { path: this._path, type: this._type } }; 361 }, 362 341 363 _onRemove: function() 342 364 { 343 var node = WebInspector.domAgent.nodeForId(this._nodeId); 344 if (node) 345 delete node.breakpoints[this._domEventType]; 365 delete this._node.breakpoints[this._type]; 346 366 } 347 367 } … … 349 369 WebInspector.DOMBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype; 350 370 351 WebInspector.EventListenerBreakpoint = function(manager, frontendId, eventName)352 { 353 WebInspector.NativeBreakpoint.call(this, manager, frontendId, "EventListener");371 WebInspector.EventListenerBreakpoint = function(manager, id, enabled, eventName) 372 { 373 WebInspector.NativeBreakpoint.call(this, manager, id, enabled); 354 374 this._eventName = eventName; 355 this._condition = { eventName: this._eventName };356 this._persistentCondition = this._condition;375 if (enabled) 376 this._enable(); 357 377 } 358 378 … … 389 409 { 390 410 return WebInspector.EventListenerBreakpoint.eventNameForUI(this._eventName); 411 }, 412 413 _enable: function() 414 { 415 InspectorBackend.setEventListenerBreakpoint(this._eventName); 416 }, 417 418 _disable: function() 419 { 420 InspectorBackend.removeEventListenerBreakpoint(this._eventName); 421 }, 422 423 _serializeToJSON: function() 424 { 425 var type = WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener; 426 return { type: type, enabled: this._enabled, condition: { eventName: this._eventName } }; 391 427 } 392 428 } … … 394 430 WebInspector.EventListenerBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype; 395 431 396 WebInspector.XHRBreakpoint = function(manager, frontendId, url)397 { 398 WebInspector.NativeBreakpoint.call(this, manager, frontendId, "XHR");432 WebInspector.XHRBreakpoint = function(manager, id, enabled, url) 433 { 434 WebInspector.NativeBreakpoint.call(this, manager, id, enabled); 399 435 this._url = url; 400 this._condition = { url: this._url };401 this._persistentCondition = this._condition;436 if (enabled) 437 this._enable(); 402 438 } 403 439 … … 428 464 var status = WebInspector.UIString("Paused on a XMLHttpRequest."); 429 465 element.appendChild(document.createTextNode(status)); 466 }, 467 468 _enable: function() 469 { 470 InspectorBackend.setXHRBreakpoint(this._url); 471 }, 472 473 _disable: function() 474 { 475 InspectorBackend.removeXHRBreakpoint(this._url); 476 }, 477 478 _serializeToJSON: function() 479 { 480 var type = WebInspector.BreakpointManager.NativeBreakpointTypes.XHR; 481 return { type: type, enabled: this._enabled, condition: { url: this._url } }; 430 482 } 431 483 } -
trunk/WebCore/inspector/front-end/CallStackSidebarPane.js
r73501 r73726 27 27 { 28 28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); 29 WebInspector. debuggerModel.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this);29 WebInspector.breakpointManager.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this); 30 30 WebInspector.debuggerModel.addEventListener("script-breakpoint-hit", this._scriptBreakpointHit, this); 31 31 } … … 174 174 _nativeBreakpointHit: function(event) 175 175 { 176 var breakpoint = WebInspector.breakpointManager.findBreakpoint(event.data.breakpointId); 177 if (!breakpoint) 178 return; 176 var breakpoint = event.data.breakpoint; 179 177 var statusMessageElement = document.createElement("div"); 180 178 statusMessageElement.className = "info"; -
trunk/WebCore/inspector/front-end/DebuggerModel.js
r73501 r73726 135 135 return; 136 136 if (details.eventType === WebInspector.DebuggerEventTypes.NativeBreakpoint) { 137 var breakpointId = details.eventData.breakpointId; 138 this.dispatchEventToListeners("native-breakpoint-hit", { breakpointId: breakpointId, eventData: details.eventData }); 137 this.dispatchEventToListeners("native-breakpoint-hit", details.eventData); 139 138 return; 140 139 }
Note: See TracChangeset
for help on using the changeset viewer.