InspectorDOMDebuggerAgent.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2011 Google Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef InspectorDOMDebuggerAgent_h
  31. #define InspectorDOMDebuggerAgent_h
  32. #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
  33. #include "InspectorBaseAgent.h"
  34. #include "InspectorDebuggerAgent.h"
  35. #include <wtf/HashMap.h>
  36. #include <wtf/PassOwnPtr.h>
  37. #include <wtf/RefCounted.h>
  38. #include <wtf/text/WTFString.h>
  39. namespace WebCore {
  40. class Element;
  41. class InspectorAgent;
  42. class InspectorDOMAgent;
  43. class InspectorDebuggerAgent;
  44. class InspectorFrontend;
  45. class InspectorObject;
  46. class InspectorState;
  47. class InstrumentingAgents;
  48. class Node;
  49. typedef String ErrorString;
  50. class InspectorDOMDebuggerAgent : public InspectorBaseAgent<InspectorDOMDebuggerAgent>, public InspectorDebuggerAgent::Listener, public InspectorBackendDispatcher::DOMDebuggerCommandHandler {
  51. WTF_MAKE_NONCOPYABLE(InspectorDOMDebuggerAgent);
  52. public:
  53. static PassOwnPtr<InspectorDOMDebuggerAgent> create(InstrumentingAgents*, InspectorCompositeState*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*);
  54. virtual ~InspectorDOMDebuggerAgent();
  55. // DOMDebugger API for InspectorFrontend
  56. virtual void setXHRBreakpoint(ErrorString*, const String& url);
  57. virtual void removeXHRBreakpoint(ErrorString*, const String& url);
  58. virtual void setEventListenerBreakpoint(ErrorString*, const String& eventName);
  59. virtual void removeEventListenerBreakpoint(ErrorString*, const String& eventName);
  60. virtual void setInstrumentationBreakpoint(ErrorString*, const String& eventName);
  61. virtual void removeInstrumentationBreakpoint(ErrorString*, const String& eventName);
  62. virtual void setDOMBreakpoint(ErrorString*, int nodeId, const String& type);
  63. virtual void removeDOMBreakpoint(ErrorString*, int nodeId, const String& type);
  64. // InspectorInstrumentation API
  65. void willInsertDOMNode(Node* parent);
  66. void didInvalidateStyleAttr(Node*);
  67. void didInsertDOMNode(Node*);
  68. void willRemoveDOMNode(Node*);
  69. void didRemoveDOMNode(Node*);
  70. void willModifyDOMAttr(Element*);
  71. void willSendXMLHttpRequest(const String& url);
  72. void pauseOnNativeEventIfNeeded(bool isDOMEvent, const String& eventName, bool synchronous);
  73. void didProcessTask();
  74. virtual void clearFrontend();
  75. virtual void discardAgent();
  76. private:
  77. InspectorDOMDebuggerAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*);
  78. // InspectorDebuggerAgent::Listener implementation.
  79. virtual void debuggerWasEnabled();
  80. virtual void debuggerWasDisabled();
  81. virtual void stepInto();
  82. virtual void didPause();
  83. void disable();
  84. void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, InspectorObject* description);
  85. void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set);
  86. bool hasBreakpoint(Node*, int type);
  87. void discardBindings();
  88. void setBreakpoint(ErrorString*, const String& eventName);
  89. void removeBreakpoint(ErrorString*, const String& eventName);
  90. void clear();
  91. InspectorDOMAgent* m_domAgent;
  92. InspectorDebuggerAgent* m_debuggerAgent;
  93. HashMap<Node*, uint32_t> m_domBreakpoints;
  94. bool m_pauseInNextEventListener;
  95. };
  96. } // namespace WebCore
  97. #endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
  98. #endif // !defined(InspectorDOMDebuggerAgent_h)