1/*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#pragma once
33
34#include "WebDebuggerAgent.h"
35
36namespace WebCore {
37
38class Document;
39class EventListener;
40class EventTarget;
41class Page;
42class RegisteredEventListener;
43class TimerBase;
44
45class PageDebuggerAgent final : public WebDebuggerAgent {
46 WTF_MAKE_NONCOPYABLE(PageDebuggerAgent);
47 WTF_MAKE_FAST_ALLOCATED;
48public:
49 PageDebuggerAgent(PageAgentContext&);
50 virtual ~PageDebuggerAgent() = default;
51
52 void didClearMainFrameWindowObject();
53
54 void mainFrameStartedLoading();
55 void mainFrameStoppedLoading();
56 void mainFrameNavigated();
57
58 void didRequestAnimationFrame(int callbackId, Document&);
59 void willFireAnimationFrame(int callbackId);
60 void didCancelAnimationFrame(int callbackId);
61
62 void didAddEventListener(EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
63 void willRemoveEventListener(EventTarget&, const AtomicString& eventType, EventListener&, bool capture);
64 void willHandleEvent(const RegisteredEventListener&);
65
66 void didPostMessage(const TimerBase&, JSC::ExecState&);
67 void didFailPostMessage(const TimerBase&);
68 void willDispatchPostMessage(const TimerBase&);
69 void didDispatchPostMessage(const TimerBase&);
70
71protected:
72 void enable() override;
73 void disable(bool isBeingDestroyed) override;
74
75 String sourceMapURLForScript(const Script&) override;
76
77 void didClearAsyncStackTraceData() override;
78
79private:
80 void muteConsole() override;
81 void unmuteConsole() override;
82
83 void breakpointActionLog(JSC::ExecState&, const String&) override;
84
85 Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
86
87 Page& m_inspectedPage;
88
89 HashMap<const RegisteredEventListener*, int> m_registeredEventListeners;
90 HashMap<const TimerBase*, int> m_postMessageTimers;
91 int m_nextEventListenerIdentifier { 1 };
92 int m_nextPostMessageIdentifier { 1 };
93};
94
95} // namespace WebCore
96