Home | History | Annotate | Download | only in inspector
      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 blink {
     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     WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(InspectorDOMDebuggerAgent);
     65 public:
     66     static PassOwnPtrWillBeRawPtr<InspectorDOMDebuggerAgent> create(InspectorDOMAgent*, InspectorDebuggerAgent*);
     67 
     68     virtual ~InspectorDOMDebuggerAgent();
     69     virtual void trace(Visitor*) OVERRIDE;
     70 
     71     // DOMDebugger API for InspectorFrontend
     72     virtual void setXHRBreakpoint(ErrorString*, const String& url) OVERRIDE;
     73     virtual void removeXHRBreakpoint(ErrorString*, const String& url) OVERRIDE;
     74     virtual void setEventListenerBreakpoint(ErrorString*, const String& eventName, const String* targetName) OVERRIDE;
     75     virtual void removeEventListenerBreakpoint(ErrorString*, const String& eventName, const String* targetName) OVERRIDE;
     76     virtual void setInstrumentationBreakpoint(ErrorString*, const String& eventName) OVERRIDE;
     77     virtual void removeInstrumentationBreakpoint(ErrorString*, const String& eventName) OVERRIDE;
     78     virtual void setDOMBreakpoint(ErrorString*, int nodeId, const String& type) OVERRIDE;
     79     virtual void removeDOMBreakpoint(ErrorString*, int nodeId, const String& type) OVERRIDE;
     80 
     81     // InspectorInstrumentation API
     82     void willInsertDOMNode(Node* parent);
     83     void didInvalidateStyleAttr(Node*);
     84     void didInsertDOMNode(Node*);
     85     void willRemoveDOMNode(Node*);
     86     void didRemoveDOMNode(Node*);
     87     void willModifyDOMAttr(Element*, const AtomicString&, const AtomicString&);
     88     void willSendXMLHttpRequest(const String& url);
     89     void didInstallTimer(ExecutionContext*, int timerId, int timeout, bool singleShot);
     90     void didRemoveTimer(ExecutionContext*, int timerId);
     91     void willFireTimer(ExecutionContext*, int timerId);
     92     void didRequestAnimationFrame(Document*, int callbackId);
     93     void didCancelAnimationFrame(Document*, int callbackId);
     94     void willFireAnimationFrame(Document*, int callbackId);
     95     void willHandleEvent(EventTarget*, Event*, EventListener*, bool useCapture);
     96     void didFireWebGLError(const String& errorName);
     97     void didFireWebGLWarning();
     98     void didFireWebGLErrorOrWarning(const String& message);
     99     void willExecuteCustomElementCallback(Element*);
    100     void willCloseWindow();
    101 
    102     void didProcessTask();
    103 
    104     virtual void clearFrontend() OVERRIDE;
    105     virtual void discardAgent() OVERRIDE;
    106 
    107 private:
    108     InspectorDOMDebuggerAgent(InspectorDOMAgent*, InspectorDebuggerAgent*);
    109 
    110     void pauseOnNativeEventIfNeeded(PassRefPtr<JSONObject> eventData, bool synchronous);
    111     PassRefPtr<JSONObject> preparePauseOnNativeEventData(const String& eventName, const String* targetName);
    112 
    113     // InspectorDOMAgent::Listener implementation.
    114     virtual void domAgentWasEnabled() OVERRIDE;
    115     virtual void domAgentWasDisabled() OVERRIDE;
    116 
    117     // InspectorDebuggerAgent::Listener implementation.
    118     virtual void debuggerWasEnabled() OVERRIDE;
    119     virtual void debuggerWasDisabled() OVERRIDE;
    120     virtual void stepInto() OVERRIDE;
    121     virtual void didPause() OVERRIDE;
    122     virtual bool canPauseOnPromiseEvent() OVERRIDE;
    123     virtual void didCreatePromise() OVERRIDE;
    124     virtual void didResolvePromise() OVERRIDE;
    125     virtual void didRejectPromise() OVERRIDE;
    126     void disable();
    127 
    128     void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, JSONObject* description);
    129     void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set);
    130     bool hasBreakpoint(Node*, int type);
    131     void setBreakpoint(ErrorString*, const String& eventName, const String* targetName);
    132     void removeBreakpoint(ErrorString*, const String& eventName, const String* targetName);
    133 
    134     void clear();
    135 
    136     RawPtrWillBeMember<InspectorDOMAgent> m_domAgent;
    137     RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent;
    138     WillBeHeapHashMap<RawPtrWillBeMember<Node>, uint32_t> m_domBreakpoints;
    139     bool m_pauseInNextEventListener;
    140 };
    141 
    142 } // namespace blink
    143 
    144 
    145 #endif // !defined(InspectorDOMDebuggerAgent_h)
    146