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