2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
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
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.
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.
34 #include "CSSSelector.h"
35 #include "CallTracerTypes.h"
36 #include "CanvasBase.h"
37 #include "CanvasRenderingContext.h"
39 #include "DocumentThreadableLoader.h"
41 #include "EventTarget.h"
44 #include "HitTestResult.h"
45 #include "InspectorController.h"
46 #include "InspectorInstrumentationCookie.h"
47 #include "InspectorInstrumentationPublic.h"
48 #include "OffscreenCanvas.h"
50 #include "StorageArea.h"
51 #include "WorkerGlobalScope.h"
52 #include "WorkerInspectorController.h"
53 #include <JavaScriptCore/JSCInlines.h>
54 #include <initializer_list>
55 #include <wtf/CompletionHandler.h>
56 #include <wtf/MemoryPressureHandler.h>
57 #include <wtf/RefPtr.h>
60 #include "WebGLRenderingContextBase.h"
64 #include "GPUCanvasContext.h"
65 #include "WebGPUDevice.h"
70 class ScriptArguments;
71 class ScriptCallStack;
79 class DOMWrapperWorld;
84 class InspectorTimelineAgent;
85 class InstrumentingAgents;
86 class NetworkLoadMetrics;
89 class RegisteredEventListener;
93 class ResourceRequest;
94 class ResourceResponse;
95 class ScriptExecutionContext;
100 class WebKitNamedFlow;
101 class WorkerInspectorProxy;
108 class WebGPUSwapChain;
111 enum class StorageType;
113 struct WebSocketFrame;
115 class InspectorInstrumentation {
117 static void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
118 static bool isDebuggerPaused(Frame*);
120 static int identifierForNode(Node&);
121 static void addEventListenersToNode(Node&);
122 static void willInsertDOMNode(Document&, Node& parent);
123 static void didInsertDOMNode(Document&, Node&);
124 static void willRemoveDOMNode(Document&, Node&);
125 static void didRemoveDOMNode(Document&, Node&);
126 static void willModifyDOMAttr(Document&, Element&, const AtomString& oldValue, const AtomString& newValue);
127 static void didModifyDOMAttr(Document&, Element&, const AtomString& name, const AtomString& value);
128 static void didRemoveDOMAttr(Document&, Element&, const AtomString& name);
129 static void characterDataModified(Document&, CharacterData&);
130 static void willInvalidateStyleAttr(Element&);
131 static void didInvalidateStyleAttr(Element&);
132 static void documentDetached(Document&);
133 static void frameWindowDiscarded(Frame&, DOMWindow*);
134 static void mediaQueryResultChanged(Document&);
135 static void activeStyleSheetsUpdated(Document&);
136 static void didPushShadowRoot(Element& host, ShadowRoot&);
137 static void willPopShadowRoot(Element& host, ShadowRoot&);
138 static void didChangeCustomElementState(Element&);
139 static void pseudoElementCreated(Page*, PseudoElement&);
140 static void pseudoElementDestroyed(Page*, PseudoElement&);
141 static void didCreateNamedFlow(Document*, WebKitNamedFlow&);
142 static void willRemoveNamedFlow(Document*, WebKitNamedFlow&);
143 static void didChangeRegionOverset(Document&, WebKitNamedFlow&);
144 static void didRegisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
145 static void didUnregisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement);
147 static void mouseDidMoveOverElement(Page&, const HitTestResult&, unsigned modifierFlags);
148 static bool handleMousePress(Frame&);
149 static bool handleTouchEvent(Frame&, Node&);
150 static bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
152 static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
153 static void willFetch(ScriptExecutionContext&, const String& url);
154 static void didInstallTimer(ScriptExecutionContext&, int timerId, Seconds timeout, bool singleShot);
155 static void didRemoveTimer(ScriptExecutionContext&, int timerId);
157 static void didPostMessage(Frame&, TimerBase&, JSC::ExecState&);
158 static void didFailPostMessage(Frame&, TimerBase&);
159 static void willDispatchPostMessage(Frame&, TimerBase&);
160 static void didDispatchPostMessage(Frame&, TimerBase&);
162 static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine, int scriptColumn);
163 static void didCallFunction(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
164 static void didAddEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
165 static void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
166 static bool isEventListenerDisabled(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
167 static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
168 static void didDispatchEvent(const InspectorInstrumentationCookie&, bool defaultPrevented);
169 static void willHandleEvent(ScriptExecutionContext&, Event&, const RegisteredEventListener&);
170 static void didHandleEvent(ScriptExecutionContext&);
171 static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
172 static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&, bool defaultPrevented);
173 static void eventDidResetAfterDispatch(const Event&);
174 static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber, int columnNumber);
175 static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame&);
176 static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext&, int timerId, bool oneShot);
177 static void didFireTimer(const InspectorInstrumentationCookie&);
178 static void didInvalidateLayout(Frame&);
179 static InspectorInstrumentationCookie willLayout(Frame&);
180 static void didLayout(const InspectorInstrumentationCookie&, RenderObject&);
181 static void didScroll(Page&);
182 static void willComposite(Frame&);
183 static void didComposite(Frame&);
184 static void willPaint(RenderObject&);
185 static void didPaint(RenderObject&, const LayoutRect&);
186 static InspectorInstrumentationCookie willRecalculateStyle(Document&);
187 static void didRecalculateStyle(const InspectorInstrumentationCookie&);
188 static void didScheduleStyleRecalculation(Document&);
189 static void applyUserAgentOverride(Frame&, String&);
190 static void applyEmulatedMedia(Frame&, String&);
192 static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
193 static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
194 static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
195 static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
196 static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
197 static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);
198 static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
200 static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
201 static void didReceiveResourceResponse(WorkerGlobalScope&, unsigned long identifier, const ResourceResponse&);
202 static void didReceiveData(WorkerGlobalScope&, unsigned long identifier, const char* data, int dataLength);
203 static void didFinishLoading(WorkerGlobalScope&, unsigned long identifier, const NetworkLoadMetrics&);
204 static void didFailLoading(WorkerGlobalScope&, unsigned long identifier, const ResourceError&);
206 // Some network requests do not go through the normal network loading path.
207 // These network requests have to issue their own willSendRequest / didReceiveResponse / didFinishLoading / didFailLoading
208 // instrumentation calls. Some of these loads are for resources that lack a CachedResource::Type.
209 enum class LoadType { Ping, Beacon };
210 static void willSendRequestOfType(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
212 static void continueAfterXFrameOptionsDenied(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
213 static void continueWithPolicyDownload(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
214 static void continueWithPolicyIgnore(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
215 static void willLoadXHRSynchronously(ScriptExecutionContext*);
216 static void didLoadXHRSynchronously(ScriptExecutionContext*);
217 static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString);
218 static void scriptExecutionBlockedByCSP(ScriptExecutionContext*, const String& directiveText);
219 static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier);
220 static void domContentLoadedEventFired(Frame&);
221 static void loadEventFired(Frame*);
222 static void frameDetachedFromParent(Frame&);
223 static void didCommitLoad(Frame&, DocumentLoader*);
224 static void frameDocumentUpdated(Frame&);
225 static void loaderDetachedFromFrame(Frame&, DocumentLoader&);
226 static void frameStartedLoading(Frame&);
227 static void frameStoppedLoading(Frame&);
228 static void frameScheduledNavigation(Frame&, Seconds delay);
229 static void frameClearedScheduledNavigation(Frame&);
230 static void defaultAppearanceDidChange(Page&, bool useDarkAppearance);
231 static void willDestroyCachedResource(CachedResource&);
233 static bool willInterceptRequest(const Frame*, const ResourceRequest&);
234 static bool shouldInterceptResponse(const Frame&, const ResourceResponse&);
235 static void interceptResponse(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
237 static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
238 static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>);
240 static void consoleCount(Page&, JSC::ExecState*, const String& label);
241 static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, const String& label);
242 static void consoleCountReset(Page&, JSC::ExecState*, const String& label);
243 static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, const String& label);
245 static void takeHeapSnapshot(Frame&, const String& title);
246 static void startConsoleTiming(Frame&, JSC::ExecState*, const String& label);
247 static void startConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
248 static void logConsoleTiming(Frame&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
249 static void logConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
250 static void stopConsoleTiming(Frame&, JSC::ExecState*, const String& label);
251 static void stopConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
252 static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
253 static void startProfiling(Page&, JSC::ExecState*, const String& title);
254 static void stopProfiling(Page&, JSC::ExecState*, const String& title);
255 static void consoleStartRecordingCanvas(CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
257 static void didRequestAnimationFrame(Document&, int callbackId);
258 static void didCancelAnimationFrame(Document&, int callbackId);
259 static InspectorInstrumentationCookie willFireAnimationFrame(Document&, int callbackId);
260 static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
262 static InspectorInstrumentationCookie willFireObserverCallback(ScriptExecutionContext&, const String& callbackType);
263 static void didFireObserverCallback(const InspectorInstrumentationCookie&);
265 static void didOpenDatabase(Database&);
267 static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
269 static bool shouldWaitForDebuggerOnStart(ScriptExecutionContext&);
270 static void workerStarted(ScriptExecutionContext&, WorkerInspectorProxy*, const URL&);
271 static void workerTerminated(ScriptExecutionContext&, WorkerInspectorProxy*);
273 static void didCreateWebSocket(Document*, unsigned long identifier, const URL& requestURL);
274 static void willSendWebSocketHandshakeRequest(Document*, unsigned long identifier, const ResourceRequest&);
275 static void didReceiveWebSocketHandshakeResponse(Document*, unsigned long identifier, const ResourceResponse&);
276 static void didCloseWebSocket(Document*, unsigned long identifier);
277 static void didReceiveWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
278 static void didSendWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
279 static void didReceiveWebSocketFrameError(Document*, unsigned long identifier, const String& errorMessage);
281 #if ENABLE(RESOURCE_USAGE)
282 static void didHandleMemoryPressure(Page&, Critical);
285 static void didChangeCSSCanvasClientNodes(CanvasBase&);
286 static void didCreateCanvasRenderingContext(CanvasRenderingContext&);
287 static void didChangeCanvasMemory(CanvasRenderingContext&);
288 static void recordCanvasAction(CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
289 static void didFinishRecordingCanvasFrame(CanvasRenderingContext&, bool forceDispatch = false);
291 static void didEnableExtension(WebGLRenderingContextBase&, const String&);
292 static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
293 static void willDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&);
294 static bool isShaderProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
295 static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
298 static void didCreateWebGPUDevice(WebGPUDevice&);
299 static void willDestroyWebGPUDevice(WebGPUDevice&);
300 static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
303 static void networkStateChanged(Page&);
304 static void updateApplicationCacheStatus(Frame*);
306 static void layerTreeDidChange(Page*);
307 static void renderLayerDestroyed(Page*, const RenderLayer&);
309 static void frontendCreated();
310 static void frontendDeleted();
311 static bool hasFrontends() { return InspectorInstrumentationPublic::hasFrontends(); }
313 static void firstFrontendCreated();
314 static void lastFrontendDeleted();
316 static bool consoleAgentEnabled(ScriptExecutionContext*);
317 static bool timelineAgentTracking(ScriptExecutionContext*);
319 static InstrumentingAgents* instrumentingAgentsForPage(Page*);
321 static void registerInstrumentingAgents(InstrumentingAgents&);
322 static void unregisterInstrumentingAgents(InstrumentingAgents&);
325 static void didClearWindowObjectInWorldImpl(InstrumentingAgents&, Frame&, DOMWrapperWorld&);
326 static bool isDebuggerPausedImpl(InstrumentingAgents&);
328 static int identifierForNodeImpl(InstrumentingAgents&, Node&);
329 static void addEventListenersToNodeImpl(InstrumentingAgents&, Node&);
330 static void willInsertDOMNodeImpl(InstrumentingAgents&, Node& parent);
331 static void didInsertDOMNodeImpl(InstrumentingAgents&, Node&);
332 static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
333 static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
334 static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& oldValue, const AtomString& newValue);
335 static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name, const AtomString& value);
336 static void didRemoveDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name);
337 static void characterDataModifiedImpl(InstrumentingAgents&, CharacterData&);
338 static void willInvalidateStyleAttrImpl(InstrumentingAgents&, Element&);
339 static void didInvalidateStyleAttrImpl(InstrumentingAgents&, Element&);
340 static void documentDetachedImpl(InstrumentingAgents&, Document&);
341 static void frameWindowDiscardedImpl(InstrumentingAgents&, DOMWindow*);
342 static void mediaQueryResultChangedImpl(InstrumentingAgents&);
343 static void activeStyleSheetsUpdatedImpl(InstrumentingAgents&, Document&);
344 static void didPushShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
345 static void willPopShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
346 static void didChangeCustomElementStateImpl(InstrumentingAgents&, Element&);
347 static void pseudoElementCreatedImpl(InstrumentingAgents&, PseudoElement&);
348 static void pseudoElementDestroyedImpl(InstrumentingAgents&, PseudoElement&);
349 static void didCreateNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
350 static void willRemoveNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
351 static void didChangeRegionOversetImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&);
352 static void didRegisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
353 static void didUnregisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement);
355 static void mouseDidMoveOverElementImpl(InstrumentingAgents&, const HitTestResult&, unsigned modifierFlags);
356 static bool handleMousePressImpl(InstrumentingAgents&);
357 static bool handleTouchEventImpl(InstrumentingAgents&, Node&);
358 static bool forcePseudoStateImpl(InstrumentingAgents&, const Element&, CSSSelector::PseudoClassType);
360 static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
361 static void willFetchImpl(InstrumentingAgents&, const String& url);
362 static void didInstallTimerImpl(InstrumentingAgents&, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext&);
363 static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
365 static void didPostMessageImpl(InstrumentingAgents&, const TimerBase&, JSC::ExecState&);
366 static void didFailPostMessageImpl(InstrumentingAgents&, const TimerBase&);
367 static void willDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
368 static void didDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
370 static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, int scriptColumn, ScriptExecutionContext*);
371 static void didCallFunctionImpl(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
372 static void didAddEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
373 static void willRemoveEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
374 static bool isEventListenerDisabledImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
375 static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners);
376 static void willHandleEventImpl(InstrumentingAgents&, Event&, const RegisteredEventListener&);
377 static void didHandleEventImpl(InstrumentingAgents&);
378 static void didDispatchEventImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
379 static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
380 static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
381 static void eventDidResetAfterDispatchImpl(InstrumentingAgents&, const Event&);
382 static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber, int columnNumber);
383 static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame&);
384 static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents&, int timerId, bool oneShot, ScriptExecutionContext&);
385 static void didFireTimerImpl(const InspectorInstrumentationCookie&);
386 static void didInvalidateLayoutImpl(InstrumentingAgents&, Frame&);
387 static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents&, Frame&);
388 static void didLayoutImpl(const InspectorInstrumentationCookie&, RenderObject&);
389 static void didScrollImpl(InstrumentingAgents&);
390 static void willCompositeImpl(InstrumentingAgents&, Frame&);
391 static void didCompositeImpl(InstrumentingAgents&);
392 static void willPaintImpl(InstrumentingAgents&, RenderObject&);
393 static void didPaintImpl(InstrumentingAgents&, RenderObject&, const LayoutRect&);
394 static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents&, Document&);
395 static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
396 static void didScheduleStyleRecalculationImpl(InstrumentingAgents&, Document&);
397 static void applyUserAgentOverrideImpl(InstrumentingAgents&, String&);
398 static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
400 static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
401 static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
402 static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
403 static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
404 static void didReceiveResourceResponseImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
405 static void didReceiveThreadableLoaderResponseImpl(InstrumentingAgents&, DocumentThreadableLoader&, unsigned long identifier);
406 static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
407 static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
408 static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
409 static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
410 static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
411 static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
412 static void scriptExecutionBlockedByCSPImpl(InstrumentingAgents&, const String& directiveText);
413 static void didReceiveScriptResponseImpl(InstrumentingAgents&, unsigned long identifier);
414 static void domContentLoadedEventFiredImpl(InstrumentingAgents&, Frame&);
415 static void loadEventFiredImpl(InstrumentingAgents&, Frame*);
416 static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&);
417 static void didCommitLoadImpl(InstrumentingAgents&, Frame&, DocumentLoader*);
418 static void frameDocumentUpdatedImpl(InstrumentingAgents&, Frame&);
419 static void loaderDetachedFromFrameImpl(InstrumentingAgents&, DocumentLoader&);
420 static void frameStartedLoadingImpl(InstrumentingAgents&, Frame&);
421 static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
422 static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, Seconds delay);
423 static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
424 static void defaultAppearanceDidChangeImpl(InstrumentingAgents&, bool useDarkAppearance);
425 static void willDestroyCachedResourceImpl(CachedResource&);
427 static bool willInterceptRequestImpl(InstrumentingAgents&, const ResourceRequest&);
428 static bool shouldInterceptResponseImpl(InstrumentingAgents&, const ResourceResponse&);
429 static void interceptResponseImpl(InstrumentingAgents&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
431 static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
433 static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
434 static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
435 static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
436 static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
437 static void startConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
438 static void logConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
439 static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
440 static void stopConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
441 static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
442 static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
443 static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
444 static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
446 static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
447 static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
448 static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
449 static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
451 static InspectorInstrumentationCookie willFireObserverCallbackImpl(InstrumentingAgents&, const String&, ScriptExecutionContext&);
452 static void didFireObserverCallbackImpl(const InspectorInstrumentationCookie&);
454 static void didOpenDatabaseImpl(InstrumentingAgents&, Database&);
456 static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
458 static bool shouldWaitForDebuggerOnStartImpl(InstrumentingAgents&);
459 static void workerStartedImpl(InstrumentingAgents&, WorkerInspectorProxy*, const URL&);
460 static void workerTerminatedImpl(InstrumentingAgents&, WorkerInspectorProxy*);
462 static void didCreateWebSocketImpl(InstrumentingAgents&, unsigned long identifier, const URL& requestURL);
463 static void willSendWebSocketHandshakeRequestImpl(InstrumentingAgents&, unsigned long identifier, const ResourceRequest&);
464 static void didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents&, unsigned long identifier, const ResourceResponse&);
465 static void didCloseWebSocketImpl(InstrumentingAgents&, unsigned long identifier);
466 static void didReceiveWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
467 static void didSendWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
468 static void didReceiveWebSocketFrameErrorImpl(InstrumentingAgents&, unsigned long identifier, const String&);
470 #if ENABLE(RESOURCE_USAGE)
471 static void didHandleMemoryPressureImpl(InstrumentingAgents&, Critical);
474 static void networkStateChangedImpl(InstrumentingAgents&);
475 static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&);
477 static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents&, CanvasBase&);
478 static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, CanvasRenderingContext&);
479 static void didChangeCanvasMemoryImpl(InstrumentingAgents&, CanvasRenderingContext&);
480 static void recordCanvasActionImpl(InstrumentingAgents&, CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
481 static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, CanvasRenderingContext&, bool forceDispatch = false);
483 static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
484 static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
485 static void willDeleteProgramImpl(InstrumentingAgents&, WebGLProgram&);
486 static bool isShaderProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
487 static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
490 static void didCreateWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
491 static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
492 static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&);
495 static void layerTreeDidChangeImpl(InstrumentingAgents&);
496 static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
498 static InstrumentingAgents& instrumentingAgentsForPage(Page&);
499 static InstrumentingAgents& instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope&);
501 static InstrumentingAgents* instrumentingAgentsForFrame(const Frame&);
502 static InstrumentingAgents* instrumentingAgentsForFrame(const Frame*);
503 static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext*);
504 static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext&);
505 static InstrumentingAgents* instrumentingAgentsForDocument(Document&);
506 static InstrumentingAgents* instrumentingAgentsForDocument(Document*);
507 static InstrumentingAgents* instrumentingAgentsForRenderer(RenderObject&);
508 static InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope*);
510 static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
513 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
515 FAST_RETURN_IF_NO_FRONTENDS(void());
516 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
517 didClearWindowObjectInWorldImpl(*instrumentingAgents, frame, world);
520 inline bool InspectorInstrumentation::isDebuggerPaused(Frame* frame)
522 FAST_RETURN_IF_NO_FRONTENDS(false);
523 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
524 return isDebuggerPausedImpl(*instrumentingAgents);
528 inline int InspectorInstrumentation::identifierForNode(Node& node)
530 FAST_RETURN_IF_NO_FRONTENDS(0);
531 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(node.document()))
532 return identifierForNodeImpl(*instrumentingAgents, node);
536 inline void InspectorInstrumentation::addEventListenersToNode(Node& node)
538 FAST_RETURN_IF_NO_FRONTENDS(void());
539 if (auto* instrumentingAgents = instrumentingAgentsForDocument(node.document()))
540 addEventListenersToNodeImpl(*instrumentingAgents, node);
543 inline void InspectorInstrumentation::willInsertDOMNode(Document& document, Node& parent)
545 FAST_RETURN_IF_NO_FRONTENDS(void());
546 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
547 willInsertDOMNodeImpl(*instrumentingAgents, parent);
550 inline void InspectorInstrumentation::didInsertDOMNode(Document& document, Node& node)
552 FAST_RETURN_IF_NO_FRONTENDS(void());
553 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
554 didInsertDOMNodeImpl(*instrumentingAgents, node);
557 inline void InspectorInstrumentation::willRemoveDOMNode(Document& document, Node& node)
559 FAST_RETURN_IF_NO_FRONTENDS(void());
560 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
561 willRemoveDOMNodeImpl(*instrumentingAgents, node);
564 inline void InspectorInstrumentation::didRemoveDOMNode(Document& document, Node& node)
566 FAST_RETURN_IF_NO_FRONTENDS(void());
567 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
568 didRemoveDOMNodeImpl(*instrumentingAgents, node);
571 inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomString& oldValue, const AtomString& newValue)
573 FAST_RETURN_IF_NO_FRONTENDS(void());
574 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
575 willModifyDOMAttrImpl(*instrumentingAgents, element, oldValue, newValue);
578 inline void InspectorInstrumentation::didModifyDOMAttr(Document& document, Element& element, const AtomString& name, const AtomString& value)
580 FAST_RETURN_IF_NO_FRONTENDS(void());
581 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
582 didModifyDOMAttrImpl(*instrumentingAgents, element, name, value);
585 inline void InspectorInstrumentation::didRemoveDOMAttr(Document& document, Element& element, const AtomString& name)
587 FAST_RETURN_IF_NO_FRONTENDS(void());
588 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
589 didRemoveDOMAttrImpl(*instrumentingAgents, element, name);
592 inline void InspectorInstrumentation::willInvalidateStyleAttr(Element& element)
594 FAST_RETURN_IF_NO_FRONTENDS(void());
595 if (auto* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
596 willInvalidateStyleAttrImpl(*instrumentingAgents, element);
599 inline void InspectorInstrumentation::didInvalidateStyleAttr(Element& element)
601 FAST_RETURN_IF_NO_FRONTENDS(void());
602 if (auto* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
603 didInvalidateStyleAttrImpl(*instrumentingAgents, element);
606 inline void InspectorInstrumentation::documentDetached(Document& document)
608 FAST_RETURN_IF_NO_FRONTENDS(void());
609 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
610 documentDetachedImpl(*instrumentingAgents, document);
613 inline void InspectorInstrumentation::frameWindowDiscarded(Frame& frame, DOMWindow* domWindow)
615 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
616 frameWindowDiscardedImpl(*instrumentingAgents, domWindow);
619 inline void InspectorInstrumentation::mediaQueryResultChanged(Document& document)
621 FAST_RETURN_IF_NO_FRONTENDS(void());
622 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
623 mediaQueryResultChangedImpl(*instrumentingAgents);
626 inline void InspectorInstrumentation::activeStyleSheetsUpdated(Document& document)
628 FAST_RETURN_IF_NO_FRONTENDS(void());
629 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
630 activeStyleSheetsUpdatedImpl(*instrumentingAgents, document);
633 inline void InspectorInstrumentation::didPushShadowRoot(Element& host, ShadowRoot& root)
635 FAST_RETURN_IF_NO_FRONTENDS(void());
636 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
637 didPushShadowRootImpl(*instrumentingAgents, host, root);
640 inline void InspectorInstrumentation::willPopShadowRoot(Element& host, ShadowRoot& root)
642 FAST_RETURN_IF_NO_FRONTENDS(void());
643 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
644 willPopShadowRootImpl(*instrumentingAgents, host, root);
647 inline void InspectorInstrumentation::didChangeCustomElementState(Element& element)
649 FAST_RETURN_IF_NO_FRONTENDS(void());
650 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
651 didChangeCustomElementStateImpl(*instrumentingAgents, element);
654 inline void InspectorInstrumentation::pseudoElementCreated(Page* page, PseudoElement& pseudoElement)
656 FAST_RETURN_IF_NO_FRONTENDS(void());
657 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
658 pseudoElementCreatedImpl(*instrumentingAgents, pseudoElement);
661 inline void InspectorInstrumentation::pseudoElementDestroyed(Page* page, PseudoElement& pseudoElement)
663 FAST_RETURN_IF_NO_FRONTENDS(void());
664 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
665 pseudoElementDestroyedImpl(*instrumentingAgents, pseudoElement);
668 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
670 FAST_RETURN_IF_NO_FRONTENDS(void());
671 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
672 didCreateNamedFlowImpl(*instrumentingAgents, document, namedFlow);
675 inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
677 FAST_RETURN_IF_NO_FRONTENDS(void());
678 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
679 willRemoveNamedFlowImpl(*instrumentingAgents, document, namedFlow);
682 inline void InspectorInstrumentation::didChangeRegionOverset(Document& document, WebKitNamedFlow& namedFlow)
684 FAST_RETURN_IF_NO_FRONTENDS(void());
685 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
686 didChangeRegionOversetImpl(*instrumentingAgents, document, namedFlow);
689 inline void InspectorInstrumentation::didRegisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement, Node* nextContentElement)
691 FAST_RETURN_IF_NO_FRONTENDS(void());
692 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
693 didRegisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement, nextContentElement);
696 inline void InspectorInstrumentation::didUnregisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement)
698 FAST_RETURN_IF_NO_FRONTENDS(void());
699 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
700 didUnregisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement);
703 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page& page, const HitTestResult& result, unsigned modifierFlags)
705 FAST_RETURN_IF_NO_FRONTENDS(void());
706 mouseDidMoveOverElementImpl(instrumentingAgentsForPage(page), result, modifierFlags);
709 inline bool InspectorInstrumentation::handleTouchEvent(Frame& frame, Node& node)
711 FAST_RETURN_IF_NO_FRONTENDS(false);
712 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
713 return handleTouchEventImpl(*instrumentingAgents, node);
717 inline bool InspectorInstrumentation::handleMousePress(Frame& frame)
719 FAST_RETURN_IF_NO_FRONTENDS(false);
720 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
721 return handleMousePressImpl(*instrumentingAgents);
725 inline bool InspectorInstrumentation::forcePseudoState(const Element& element, CSSSelector::PseudoClassType pseudoState)
727 FAST_RETURN_IF_NO_FRONTENDS(false);
728 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
729 return forcePseudoStateImpl(*instrumentingAgents, element, pseudoState);
733 inline void InspectorInstrumentation::characterDataModified(Document& document, CharacterData& characterData)
735 FAST_RETURN_IF_NO_FRONTENDS(void());
736 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
737 characterDataModifiedImpl(*instrumentingAgents, characterData);
740 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
742 FAST_RETURN_IF_NO_FRONTENDS(void());
743 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
744 willSendXMLHttpRequestImpl(*instrumentingAgents, url);
747 inline void InspectorInstrumentation::willFetch(ScriptExecutionContext& context, const String& url)
749 FAST_RETURN_IF_NO_FRONTENDS(void());
750 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
751 willFetchImpl(*instrumentingAgents, url);
754 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext& context, int timerId, Seconds timeout, bool singleShot)
756 FAST_RETURN_IF_NO_FRONTENDS(void());
757 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
758 didInstallTimerImpl(*instrumentingAgents, timerId, timeout, singleShot, context);
761 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext& context, int timerId)
763 FAST_RETURN_IF_NO_FRONTENDS(void());
764 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
765 didRemoveTimerImpl(*instrumentingAgents, timerId, context);
768 inline void InspectorInstrumentation::didAddEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
770 FAST_RETURN_IF_NO_FRONTENDS(void());
771 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
772 didAddEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
775 inline void InspectorInstrumentation::willRemoveEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
777 FAST_RETURN_IF_NO_FRONTENDS(void());
778 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
779 willRemoveEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
782 inline bool InspectorInstrumentation::isEventListenerDisabled(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
784 FAST_RETURN_IF_NO_FRONTENDS(false);
785 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
786 return isEventListenerDisabledImpl(*instrumentingAgents, target, eventType, listener, capture);
790 inline void InspectorInstrumentation::didPostMessage(Frame& frame, TimerBase& timer, JSC::ExecState& state)
792 FAST_RETURN_IF_NO_FRONTENDS(void());
793 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
794 didPostMessageImpl(*instrumentingAgents, timer, state);
797 inline void InspectorInstrumentation::didFailPostMessage(Frame& frame, TimerBase& timer)
799 FAST_RETURN_IF_NO_FRONTENDS(void());
800 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
801 didFailPostMessageImpl(*instrumentingAgents, timer);
804 inline void InspectorInstrumentation::willDispatchPostMessage(Frame& frame, TimerBase& timer)
806 FAST_RETURN_IF_NO_FRONTENDS(void());
807 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
808 willDispatchPostMessageImpl(*instrumentingAgents, timer);
811 inline void InspectorInstrumentation::didDispatchPostMessage(Frame& frame, TimerBase& timer)
813 FAST_RETURN_IF_NO_FRONTENDS(void());
814 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
815 didDispatchPostMessageImpl(*instrumentingAgents, timer);
818 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine, int scriptColumn)
820 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
821 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
822 return willCallFunctionImpl(*instrumentingAgents, scriptName, scriptLine, scriptColumn, context);
823 return InspectorInstrumentationCookie();
826 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
828 FAST_RETURN_IF_NO_FRONTENDS(void());
829 if (cookie.isValid())
830 didCallFunctionImpl(cookie, context);
833 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document& document, const Event& event, bool hasEventListeners)
835 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
836 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
837 return willDispatchEventImpl(*instrumentingAgents, document, event, hasEventListeners);
838 return InspectorInstrumentationCookie();
841 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
843 FAST_RETURN_IF_NO_FRONTENDS(void());
844 if (cookie.isValid())
845 didDispatchEventImpl(cookie, defaultPrevented);
848 inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, Event& event, const RegisteredEventListener& listener)
850 FAST_RETURN_IF_NO_FRONTENDS(void());
851 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
852 return willHandleEventImpl(*instrumentingAgents, event, listener);
855 inline void InspectorInstrumentation::didHandleEvent(ScriptExecutionContext& context)
857 FAST_RETURN_IF_NO_FRONTENDS(void());
858 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
859 return didHandleEventImpl(*instrumentingAgents);
862 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow& window)
864 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
865 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
866 return willDispatchEventOnWindowImpl(*instrumentingAgents, event, window);
867 return InspectorInstrumentationCookie();
870 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
872 FAST_RETURN_IF_NO_FRONTENDS(void());
873 if (cookie.isValid())
874 didDispatchEventOnWindowImpl(cookie, defaultPrevented);
877 inline void InspectorInstrumentation::eventDidResetAfterDispatch(const Event& event)
879 FAST_RETURN_IF_NO_FRONTENDS(void());
881 if (!is<Node>(event.target()))
884 auto* node = downcast<Node>(event.target());
885 if (auto* instrumentingAgents = instrumentingAgentsForContext(node->scriptExecutionContext()))
886 return eventDidResetAfterDispatchImpl(*instrumentingAgents, event);
889 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame& frame, const String& url, int lineNumber, int columnNumber)
891 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
892 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
893 return willEvaluateScriptImpl(*instrumentingAgents, frame, url, lineNumber, columnNumber);
894 return InspectorInstrumentationCookie();
897 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie, Frame& frame)
899 FAST_RETURN_IF_NO_FRONTENDS(void());
900 if (cookie.isValid())
901 didEvaluateScriptImpl(cookie, frame);
904 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext& context, int timerId, bool oneShot)
906 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
907 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
908 return willFireTimerImpl(*instrumentingAgents, timerId, oneShot, context);
909 return InspectorInstrumentationCookie();
912 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
914 FAST_RETURN_IF_NO_FRONTENDS(void());
915 if (cookie.isValid())
916 didFireTimerImpl(cookie);
919 inline void InspectorInstrumentation::didInvalidateLayout(Frame& frame)
921 FAST_RETURN_IF_NO_FRONTENDS(void());
922 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
923 didInvalidateLayoutImpl(*instrumentingAgents, frame);
926 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame& frame)
928 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
929 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
930 return willLayoutImpl(*instrumentingAgents, frame);
931 return InspectorInstrumentationCookie();
934 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie, RenderObject& root)
936 FAST_RETURN_IF_NO_FRONTENDS(void());
937 if (cookie.isValid())
938 didLayoutImpl(cookie, root);
941 inline void InspectorInstrumentation::didScroll(Page& page)
943 FAST_RETURN_IF_NO_FRONTENDS(void());
944 didScrollImpl(instrumentingAgentsForPage(page));
947 inline void InspectorInstrumentation::willComposite(Frame& frame)
949 FAST_RETURN_IF_NO_FRONTENDS(void());
950 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
951 willCompositeImpl(*instrumentingAgents, frame);
954 inline void InspectorInstrumentation::didComposite(Frame& frame)
956 FAST_RETURN_IF_NO_FRONTENDS(void());
957 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
958 didCompositeImpl(*instrumentingAgents);
961 inline void InspectorInstrumentation::willPaint(RenderObject& renderer)
963 FAST_RETURN_IF_NO_FRONTENDS(void());
964 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
965 return willPaintImpl(*instrumentingAgents, renderer);
968 inline void InspectorInstrumentation::didPaint(RenderObject& renderer, const LayoutRect& rect)
970 FAST_RETURN_IF_NO_FRONTENDS(void());
971 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
972 didPaintImpl(*instrumentingAgents, renderer, rect);
975 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document& document)
977 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
978 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
979 return willRecalculateStyleImpl(*instrumentingAgents, document);
980 return InspectorInstrumentationCookie();
983 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
985 FAST_RETURN_IF_NO_FRONTENDS(void());
986 if (cookie.isValid())
987 didRecalculateStyleImpl(cookie);
990 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document& document)
992 FAST_RETURN_IF_NO_FRONTENDS(void());
993 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
994 didScheduleStyleRecalculationImpl(*instrumentingAgents, document);
997 inline void InspectorInstrumentation::applyUserAgentOverride(Frame& frame, String& userAgent)
999 FAST_RETURN_IF_NO_FRONTENDS(void());
1000 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1001 applyUserAgentOverrideImpl(*instrumentingAgents, userAgent);
1004 inline void InspectorInstrumentation::applyEmulatedMedia(Frame& frame, String& media)
1006 FAST_RETURN_IF_NO_FRONTENDS(void());
1007 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1008 applyEmulatedMediaImpl(*instrumentingAgents, media);
1011 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
1013 FAST_RETURN_IF_NO_FRONTENDS(void());
1014 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1015 willSendRequestImpl(*instrumentingAgents, identifier, loader, request, redirectResponse);
1018 inline void InspectorInstrumentation::willSendRequest(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, ResourceRequest& request)
1020 FAST_RETURN_IF_NO_FRONTENDS(void());
1021 willSendRequestImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, request, ResourceResponse { });
1024 inline void InspectorInstrumentation::willSendRequestOfType(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)
1026 FAST_RETURN_IF_NO_FRONTENDS(void());
1027 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1028 willSendRequestOfTypeImpl(*instrumentingAgents, identifier, loader, request, loadType);
1031 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page& page, DocumentLoader* loader, CachedResource* resource)
1033 FAST_RETURN_IF_NO_FRONTENDS(void());
1034 didLoadResourceFromMemoryCacheImpl(instrumentingAgentsForPage(page), loader, resource);
1037 inline void InspectorInstrumentation::didReceiveResourceResponse(Frame& frame, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
1039 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1040 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, loader, response, resourceLoader);
1043 inline void InspectorInstrumentation::didReceiveResourceResponse(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceResponse& response)
1045 didReceiveResourceResponseImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, response, nullptr);
1048 inline void InspectorInstrumentation::didReceiveThreadableLoaderResponse(DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
1050 FAST_RETURN_IF_NO_FRONTENDS(void());
1051 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(documentThreadableLoader.document()))
1052 didReceiveThreadableLoaderResponseImpl(*instrumentingAgents, documentThreadableLoader, identifier);
1055 inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
1057 FAST_RETURN_IF_NO_FRONTENDS(void());
1058 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1059 didReceiveDataImpl(*instrumentingAgents, identifier, data, dataLength, encodedDataLength);
1062 inline void InspectorInstrumentation::didReceiveData(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const char* data, int dataLength)
1064 FAST_RETURN_IF_NO_FRONTENDS(void());
1065 didReceiveDataImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, data, dataLength, dataLength);
1068 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics, ResourceLoader* resourceLoader)
1070 FAST_RETURN_IF_NO_FRONTENDS(void());
1071 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1072 didFinishLoadingImpl(*instrumentingAgents, identifier, loader, networkLoadMetrics, resourceLoader);
1075 inline void InspectorInstrumentation::didFinishLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics)
1077 FAST_RETURN_IF_NO_FRONTENDS(void());
1078 didFinishLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, networkLoadMetrics, nullptr);
1081 inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
1083 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1084 didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
1087 inline void InspectorInstrumentation::didFailLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceError& error)
1089 didFailLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, error);
1092 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1094 // Treat the same as didReceiveResponse.
1095 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1096 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1099 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1101 // Treat the same as didReceiveResponse.
1102 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1103 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1106 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1108 // Treat the same as didReceiveResponse.
1109 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1110 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1113 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
1115 FAST_RETURN_IF_NO_FRONTENDS(void());
1116 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1117 willLoadXHRSynchronouslyImpl(*instrumentingAgents);
1120 inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionContext* context)
1122 FAST_RETURN_IF_NO_FRONTENDS(void());
1123 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1124 didLoadXHRSynchronouslyImpl(*instrumentingAgents);
1127 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext& context, unsigned long identifier, const String& sourceString)
1129 FAST_RETURN_IF_NO_FRONTENDS(void());
1130 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1131 scriptImportedImpl(*instrumentingAgents, identifier, sourceString);
1134 inline void InspectorInstrumentation::scriptExecutionBlockedByCSP(ScriptExecutionContext* context, const String& directiveText)
1136 FAST_RETURN_IF_NO_FRONTENDS(void());
1137 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1138 scriptExecutionBlockedByCSPImpl(*instrumentingAgents, directiveText);
1141 inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier)
1143 FAST_RETURN_IF_NO_FRONTENDS(void());
1144 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1145 didReceiveScriptResponseImpl(*instrumentingAgents, identifier);
1148 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame& frame)
1150 FAST_RETURN_IF_NO_FRONTENDS(void());
1151 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1152 domContentLoadedEventFiredImpl(*instrumentingAgents, frame);
1155 inline void InspectorInstrumentation::loadEventFired(Frame* frame)
1157 FAST_RETURN_IF_NO_FRONTENDS(void());
1158 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1159 loadEventFiredImpl(*instrumentingAgents, frame);
1162 inline void InspectorInstrumentation::frameDetachedFromParent(Frame& frame)
1164 FAST_RETURN_IF_NO_FRONTENDS(void());
1165 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1166 frameDetachedFromParentImpl(*instrumentingAgents, frame);
1169 inline void InspectorInstrumentation::didCommitLoad(Frame& frame, DocumentLoader* loader)
1171 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1172 didCommitLoadImpl(*instrumentingAgents, frame, loader);
1175 inline void InspectorInstrumentation::frameDocumentUpdated(Frame& frame)
1177 FAST_RETURN_IF_NO_FRONTENDS(void());
1178 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1179 frameDocumentUpdatedImpl(*instrumentingAgents, frame);
1182 inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame& frame, DocumentLoader& loader)
1184 FAST_RETURN_IF_NO_FRONTENDS(void());
1185 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1186 loaderDetachedFromFrameImpl(*instrumentingAgents, loader);
1189 inline void InspectorInstrumentation::frameStartedLoading(Frame& frame)
1191 FAST_RETURN_IF_NO_FRONTENDS(void());
1192 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1193 frameStartedLoadingImpl(*instrumentingAgents, frame);
1196 inline void InspectorInstrumentation::frameStoppedLoading(Frame& frame)
1198 FAST_RETURN_IF_NO_FRONTENDS(void());
1199 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1200 frameStoppedLoadingImpl(*instrumentingAgents, frame);
1203 inline void InspectorInstrumentation::frameScheduledNavigation(Frame& frame, Seconds delay)
1205 FAST_RETURN_IF_NO_FRONTENDS(void());
1206 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1207 frameScheduledNavigationImpl(*instrumentingAgents, frame, delay);
1210 inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& frame)
1212 FAST_RETURN_IF_NO_FRONTENDS(void());
1213 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1214 frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
1217 inline void InspectorInstrumentation::defaultAppearanceDidChange(Page& page, bool useDarkAppearance)
1219 FAST_RETURN_IF_NO_FRONTENDS(void());
1220 defaultAppearanceDidChangeImpl(instrumentingAgentsForPage(page), useDarkAppearance);
1223 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource& cachedResource)
1225 FAST_RETURN_IF_NO_FRONTENDS(void());
1226 willDestroyCachedResourceImpl(cachedResource);
1229 inline bool InspectorInstrumentation::willInterceptRequest(const Frame* frame, const ResourceRequest& request)
1231 FAST_RETURN_IF_NO_FRONTENDS(false);
1232 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1233 return willInterceptRequestImpl(*instrumentingAgents, request);
1237 inline bool InspectorInstrumentation::shouldInterceptResponse(const Frame& frame, const ResourceResponse& response)
1239 ASSERT(InspectorInstrumentationPublic::hasFrontends());
1240 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1241 return shouldInterceptResponseImpl(*instrumentingAgents, response);
1245 inline void InspectorInstrumentation::interceptResponse(const Frame& frame, const ResourceResponse& response, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&& handler)
1247 ASSERT(InspectorInstrumentation::shouldInterceptResponse(frame, response));
1248 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1249 interceptResponseImpl(*instrumentingAgents, response, identifier, WTFMove(handler));
1252 inline void InspectorInstrumentation::didOpenDatabase(Database& database)
1254 FAST_RETURN_IF_NO_FRONTENDS(void());
1255 if (auto* instrumentingAgents = instrumentingAgentsForContext(database.document()))
1256 didOpenDatabaseImpl(*instrumentingAgents, database);
1259 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
1261 FAST_RETURN_IF_NO_FRONTENDS(void());
1262 didDispatchDOMStorageEventImpl(instrumentingAgentsForPage(page), key, oldValue, newValue, storageType, securityOrigin);
1265 inline bool InspectorInstrumentation::shouldWaitForDebuggerOnStart(ScriptExecutionContext& context)
1267 FAST_RETURN_IF_NO_FRONTENDS(false);
1268 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1269 return shouldWaitForDebuggerOnStartImpl(*instrumentingAgents);
1273 inline void InspectorInstrumentation::workerStarted(ScriptExecutionContext& context, WorkerInspectorProxy* proxy, const URL& url)
1275 FAST_RETURN_IF_NO_FRONTENDS(void());
1276 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1277 workerStartedImpl(*instrumentingAgents, proxy, url);
1280 inline void InspectorInstrumentation::workerTerminated(ScriptExecutionContext& context, WorkerInspectorProxy* proxy)
1282 FAST_RETURN_IF_NO_FRONTENDS(void());
1283 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1284 workerTerminatedImpl(*instrumentingAgents, proxy);
1287 inline void InspectorInstrumentation::didCreateWebSocket(Document* document, unsigned long identifier, const URL& requestURL)
1289 FAST_RETURN_IF_NO_FRONTENDS(void());
1290 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1291 didCreateWebSocketImpl(*instrumentingAgents, identifier, requestURL);
1294 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(Document* document, unsigned long identifier, const ResourceRequest& request)
1296 FAST_RETURN_IF_NO_FRONTENDS(void());
1297 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1298 willSendWebSocketHandshakeRequestImpl(*instrumentingAgents, identifier, request);
1301 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(Document* document, unsigned long identifier, const ResourceResponse& response)
1303 FAST_RETURN_IF_NO_FRONTENDS(void());
1304 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1305 didReceiveWebSocketHandshakeResponseImpl(*instrumentingAgents, identifier, response);
1308 inline void InspectorInstrumentation::didCloseWebSocket(Document* document, unsigned long identifier)
1310 FAST_RETURN_IF_NO_FRONTENDS(void());
1311 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1312 didCloseWebSocketImpl(*instrumentingAgents, identifier);
1315 inline void InspectorInstrumentation::didReceiveWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1317 FAST_RETURN_IF_NO_FRONTENDS(void());
1318 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1319 didReceiveWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1322 inline void InspectorInstrumentation::didReceiveWebSocketFrameError(Document* document, unsigned long identifier, const String& errorMessage)
1324 FAST_RETURN_IF_NO_FRONTENDS(void());
1325 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1326 didReceiveWebSocketFrameErrorImpl(*instrumentingAgents, identifier, errorMessage);
1329 inline void InspectorInstrumentation::didSendWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1331 FAST_RETURN_IF_NO_FRONTENDS(void());
1332 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1333 didSendWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1336 #if ENABLE(RESOURCE_USAGE)
1337 inline void InspectorInstrumentation::didHandleMemoryPressure(Page& page, Critical critical)
1339 FAST_RETURN_IF_NO_FRONTENDS(void());
1340 didHandleMemoryPressureImpl(instrumentingAgentsForPage(page), critical);
1344 inline void InspectorInstrumentation::didChangeCSSCanvasClientNodes(CanvasBase& canvasBase)
1346 FAST_RETURN_IF_NO_FRONTENDS(void());
1347 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(canvasBase.scriptExecutionContext()))
1348 didChangeCSSCanvasClientNodesImpl(*instrumentingAgents, canvasBase);
1351 inline void InspectorInstrumentation::didCreateCanvasRenderingContext(CanvasRenderingContext& context)
1353 FAST_RETURN_IF_NO_FRONTENDS(void());
1354 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1355 didCreateCanvasRenderingContextImpl(*instrumentingAgents, context);
1358 inline void InspectorInstrumentation::didChangeCanvasMemory(CanvasRenderingContext& context)
1360 FAST_RETURN_IF_NO_FRONTENDS(void());
1361 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1362 didChangeCanvasMemoryImpl(*instrumentingAgents, context);
1365 inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& context, const String& name, std::initializer_list<RecordCanvasActionVariant>&& parameters)
1367 FAST_RETURN_IF_NO_FRONTENDS(void());
1368 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1369 recordCanvasActionImpl(*instrumentingAgents, context, name, WTFMove(parameters));
1372 inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
1374 FAST_RETURN_IF_NO_FRONTENDS(void());
1375 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1376 didFinishRecordingCanvasFrameImpl(*instrumentingAgents, context, forceDispatch);
1380 inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& contextWebGLBase, const String& extension)
1382 FAST_RETURN_IF_NO_FRONTENDS(void());
1383 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1384 didEnableExtensionImpl(*instrumentingAgents, contextWebGLBase, extension);
1387 inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1389 FAST_RETURN_IF_NO_FRONTENDS(void());
1390 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1391 didCreateProgramImpl(*instrumentingAgents, contextWebGLBase, program);
1394 inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1396 FAST_RETURN_IF_NO_FRONTENDS(void());
1397 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1398 willDeleteProgramImpl(*instrumentingAgents, program);
1401 inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1403 FAST_RETURN_IF_NO_FRONTENDS(false);
1404 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1405 return isShaderProgramDisabledImpl(*instrumentingAgents, program);
1409 inline bool InspectorInstrumentation::isShaderProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1411 FAST_RETURN_IF_NO_FRONTENDS(false);
1412 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1413 return isShaderProgramHighlightedImpl(*instrumentingAgents, program);
1419 inline void InspectorInstrumentation::didCreateWebGPUDevice(WebGPUDevice& device)
1421 FAST_RETURN_IF_NO_FRONTENDS(void());
1422 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1423 didCreateWebGPUDeviceImpl(*instrumentingAgents, device);
1426 inline void InspectorInstrumentation::willDestroyWebGPUDevice(WebGPUDevice& device)
1428 FAST_RETURN_IF_NO_FRONTENDS(void());
1429 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1430 willDestroyWebGPUDeviceImpl(*instrumentingAgents, device);
1433 inline void InspectorInstrumentation::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain)
1435 FAST_RETURN_IF_NO_FRONTENDS(void());
1436 if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext()))
1437 willConfigureSwapChainImpl(*instrumentingAgents, contextGPU, newSwapChain);
1441 inline void InspectorInstrumentation::networkStateChanged(Page& page)
1443 FAST_RETURN_IF_NO_FRONTENDS(void());
1444 networkStateChangedImpl(instrumentingAgentsForPage(page));
1447 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
1449 FAST_RETURN_IF_NO_FRONTENDS(void());
1450 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1451 updateApplicationCacheStatusImpl(*instrumentingAgents, *frame);
1454 inline void InspectorInstrumentation::addMessageToConsole(Page& page, std::unique_ptr<Inspector::ConsoleMessage> message)
1456 addMessageToConsoleImpl(instrumentingAgentsForPage(page), WTFMove(message));
1459 inline void InspectorInstrumentation::addMessageToConsole(WorkerGlobalScope& workerGlobalScope, std::unique_ptr<Inspector::ConsoleMessage> message)
1461 addMessageToConsoleImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), WTFMove(message));
1464 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, const String& label)
1466 consoleCountImpl(instrumentingAgentsForPage(page), state, label);
1469 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
1471 consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
1474 inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, const String& label)
1476 consoleCountResetImpl(instrumentingAgentsForPage(page), state, label);
1479 inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
1481 consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
1484 inline void InspectorInstrumentation::takeHeapSnapshot(Frame& frame, const String& title)
1486 FAST_RETURN_IF_NO_FRONTENDS(void());
1487 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1488 takeHeapSnapshotImpl(*instrumentingAgents, title);
1491 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
1493 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1494 startConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
1497 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
1499 startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
1502 inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
1504 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1505 logConsoleTimingImpl(*instrumentingAgents, exec, label, WTFMove(arguments));
1508 inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
1510 logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label, WTFMove(arguments));
1513 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
1515 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1516 stopConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
1519 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
1521 stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
1524 inline void InspectorInstrumentation::consoleTimeStamp(Frame& frame, Ref<Inspector::ScriptArguments>&& arguments)
1526 FAST_RETURN_IF_NO_FRONTENDS(void());
1527 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1528 consoleTimeStampImpl(*instrumentingAgents, frame, WTFMove(arguments));
1531 inline void InspectorInstrumentation::startProfiling(Page& page, JSC::ExecState* exec, const String &title)
1533 FAST_RETURN_IF_NO_FRONTENDS(void());
1534 startProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1537 inline void InspectorInstrumentation::stopProfiling(Page& page, JSC::ExecState* exec, const String &title)
1539 FAST_RETURN_IF_NO_FRONTENDS(void());
1540 stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1543 inline void InspectorInstrumentation::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
1545 FAST_RETURN_IF_NO_FRONTENDS(void());
1546 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1547 consoleStartRecordingCanvasImpl(*instrumentingAgents, context, exec, options);
1550 inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
1552 FAST_RETURN_IF_NO_FRONTENDS(void());
1553 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1554 didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1557 inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
1559 FAST_RETURN_IF_NO_FRONTENDS(void());
1560 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1561 didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1564 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document& document, int callbackId)
1566 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1567 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1568 return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1569 return InspectorInstrumentationCookie();
1572 inline void InspectorInstrumentation::didFireAnimationFrame(const InspectorInstrumentationCookie& cookie)
1574 FAST_RETURN_IF_NO_FRONTENDS(void());
1575 if (cookie.isValid())
1576 didFireAnimationFrameImpl(cookie);
1579 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireObserverCallback(ScriptExecutionContext& context, const String& callbackType)
1581 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1582 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1583 return willFireObserverCallbackImpl(*instrumentingAgents, callbackType, context);
1584 return InspectorInstrumentationCookie();
1587 inline void InspectorInstrumentation::didFireObserverCallback(const InspectorInstrumentationCookie& cookie)
1589 FAST_RETURN_IF_NO_FRONTENDS(void());
1590 if (cookie.isValid())
1591 didFireObserverCallbackImpl(cookie);
1594 inline void InspectorInstrumentation::layerTreeDidChange(Page* page)
1596 FAST_RETURN_IF_NO_FRONTENDS(void());
1597 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1598 layerTreeDidChangeImpl(*instrumentingAgents);
1601 inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const RenderLayer& renderLayer)
1603 FAST_RETURN_IF_NO_FRONTENDS(void());
1604 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1605 renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
1608 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
1610 return context ? instrumentingAgentsForContext(*context) : nullptr;
1613 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext& context)
1615 if (is<Document>(context))
1616 return instrumentingAgentsForPage(downcast<Document>(context).page());
1617 if (is<WorkerGlobalScope>(context))
1618 return &instrumentingAgentsForWorkerGlobalScope(downcast<WorkerGlobalScope>(context));
1622 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(const Frame* frame)
1624 return frame ? instrumentingAgentsForFrame(*frame) : nullptr;
1627 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(const Frame& frame)
1629 return instrumentingAgentsForPage(frame.page());
1632 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document* document)
1634 return document ? instrumentingAgentsForDocument(*document) : nullptr;
1637 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document& document)
1639 Page* page = document.page();
1640 if (!page && document.templateDocumentHost())
1641 page = document.templateDocumentHost()->page();
1642 return instrumentingAgentsForPage(page);
1645 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
1647 return page ? &instrumentingAgentsForPage(*page) : nullptr;
1650 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForPage(Page& page)
1652 ASSERT(isMainThread());
1653 return page.inspectorController().m_instrumentingAgents.get();
1656 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
1658 return workerGlobalScope ? &instrumentingAgentsForWorkerGlobalScope(*workerGlobalScope) : nullptr;
1661 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope& workerGlobalScope)
1663 return workerGlobalScope.inspectorController().m_instrumentingAgents;
1666 inline void InspectorInstrumentation::frontendCreated()
1668 ASSERT(isMainThread());
1669 ++InspectorInstrumentationPublic::s_frontendCounter;
1671 if (InspectorInstrumentationPublic::s_frontendCounter == 1)
1672 InspectorInstrumentation::firstFrontendCreated();
1675 inline void InspectorInstrumentation::frontendDeleted()
1677 ASSERT(isMainThread());
1678 --InspectorInstrumentationPublic::s_frontendCounter;
1680 if (!InspectorInstrumentationPublic::s_frontendCounter)
1681 InspectorInstrumentation::lastFrontendDeleted();
1684 } // namespace WebCore