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