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 31 #ifndef InspectorDOMDebuggerAgent_h 32 #define InspectorDOMDebuggerAgent_h 33 34 35 #include "core/inspector/InspectorBaseAgent.h" 36 #include "core/inspector/InspectorDebuggerAgent.h" 37 #include "wtf/HashMap.h" 38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/text/WTFString.h" 40 41 namespace WebCore { 42 43 class Document; 44 class Element; 45 class Event; 46 class InspectorDOMAgent; 47 class InspectorDebuggerAgent; 48 class InspectorFrontend; 49 class InstrumentingAgents; 50 class JSONObject; 51 class Node; 52 53 typedef String ErrorString; 54 55 class InspectorDOMDebuggerAgent : public InspectorBaseAgent<InspectorDOMDebuggerAgent>, public InspectorDebuggerAgent::Listener, public InspectorBackendDispatcher::DOMDebuggerCommandHandler { 56 WTF_MAKE_NONCOPYABLE(InspectorDOMDebuggerAgent); 57 public: 58 static PassOwnPtr<InspectorDOMDebuggerAgent> create(InstrumentingAgents*, InspectorCompositeState*, InspectorDOMAgent*, InspectorDebuggerAgent*); 59 60 virtual ~InspectorDOMDebuggerAgent(); 61 62 // DOMDebugger API for InspectorFrontend 63 virtual void setXHRBreakpoint(ErrorString*, const String& url); 64 virtual void removeXHRBreakpoint(ErrorString*, const String& url); 65 virtual void setEventListenerBreakpoint(ErrorString*, const String& eventName); 66 virtual void removeEventListenerBreakpoint(ErrorString*, const String& eventName); 67 virtual void setInstrumentationBreakpoint(ErrorString*, const String& eventName); 68 virtual void removeInstrumentationBreakpoint(ErrorString*, const String& eventName); 69 virtual void setDOMBreakpoint(ErrorString*, int nodeId, const String& type); 70 virtual void removeDOMBreakpoint(ErrorString*, int nodeId, const String& type); 71 72 // InspectorInstrumentation API 73 void willInsertDOMNode(Node* parent); 74 void didInvalidateStyleAttr(Node*); 75 void didInsertDOMNode(Node*); 76 void willRemoveDOMNode(Node*); 77 void didRemoveDOMNode(Node*); 78 void willModifyDOMAttr(Element*, const AtomicString&, const AtomicString&); 79 void willSendXMLHttpRequest(const String& url); 80 void didInstallTimer(ExecutionContext*, int timerId, int timeout, bool singleShot); 81 void didRemoveTimer(ExecutionContext*, int timerId); 82 void willFireTimer(ExecutionContext*, int timerId); 83 void didRequestAnimationFrame(Document*, int callbackId); 84 void didCancelAnimationFrame(Document*, int callbackId); 85 void willFireAnimationFrame(Document*, int callbackId); 86 void willHandleEvent(Event*); 87 void didFireWebGLError(const String& errorName); 88 void didFireWebGLWarning(); 89 void didFireWebGLErrorOrWarning(const String& message); 90 91 void didProcessTask(); 92 93 virtual void clearFrontend(); 94 virtual void discardAgent(); 95 96 private: 97 InspectorDOMDebuggerAgent(InstrumentingAgents*, InspectorCompositeState*, InspectorDOMAgent*, InspectorDebuggerAgent*); 98 99 void pauseOnNativeEventIfNeeded(PassRefPtr<JSONObject> eventData, bool synchronous); 100 PassRefPtr<JSONObject> preparePauseOnNativeEventData(bool isDOMEvent, const String& eventName); 101 102 // InspectorDebuggerAgent::Listener implementation. 103 virtual void debuggerWasEnabled(); 104 virtual void debuggerWasDisabled(); 105 virtual void stepInto(); 106 virtual void didPause(); 107 void disable(); 108 109 void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, JSONObject* description); 110 void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set); 111 bool hasBreakpoint(Node*, int type); 112 void discardBindings(); 113 void setBreakpoint(ErrorString*, const String& eventName); 114 void removeBreakpoint(ErrorString*, const String& eventName); 115 116 void clear(); 117 118 InspectorDOMAgent* m_domAgent; 119 InspectorDebuggerAgent* m_debuggerAgent; 120 HashMap<Node*, uint32_t> m_domBreakpoints; 121 bool m_pauseInNextEventListener; 122 }; 123 124 } // namespace WebCore 125 126 127 #endif // !defined(InspectorDOMDebuggerAgent_h) 128