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"
66 #include "WebGPUPipeline.h"
71 class ScriptArguments;
72 class ScriptCallStack;
80 class DOMWrapperWorld;
85 class InspectorTimelineAgent;
86 class InstrumentingAgents;
87 class NetworkLoadMetrics;
90 class RegisteredEventListener;
94 class ResourceRequest;
95 class ResourceResponse;
96 class ScriptExecutionContext;
101 class WebKitNamedFlow;
102 class WorkerInspectorProxy;
109 class WebGPUSwapChain;
112 enum class StorageType;
114 struct WebSocketFrame;
116 class InspectorInstrumentation {
118 static void didClearWindowObjectInWorld(Frame&, DOMWrapperWorld&);
119 static bool isDebuggerPaused(Frame*);
121 static int identifierForNode(Node&);
122 static void addEventListenersToNode(Node&);
123 static void willInsertDOMNode(Document&, Node& parent);
124 static void didInsertDOMNode(Document&, Node&);
125 static void willRemoveDOMNode(Document&, Node&);
126 static void didRemoveDOMNode(Document&, Node&);
127 static void willModifyDOMAttr(Document&, Element&, const AtomString& oldValue, const AtomString& newValue);
128 static void didModifyDOMAttr(Document&, Element&, const AtomString& name, const AtomString& value);
129 static void didRemoveDOMAttr(Document&, Element&, const AtomString& name);
130 static void characterDataModified(Document&, CharacterData&);
131 static void willInvalidateStyleAttr(Element&);
132 static void didInvalidateStyleAttr(Element&);
133 static void documentDetached(Document&);
134 static void frameWindowDiscarded(Frame&, DOMWindow*);
135 static void mediaQueryResultChanged(Document&);
136 static void activeStyleSheetsUpdated(Document&);
137 static void didPushShadowRoot(Element& host, ShadowRoot&);
138 static void willPopShadowRoot(Element& host, ShadowRoot&);
139 static void didChangeCustomElementState(Element&);
140 static void pseudoElementCreated(Page*, PseudoElement&);
141 static void pseudoElementDestroyed(Page*, PseudoElement&);
142 static void didCreateNamedFlow(Document*, WebKitNamedFlow&);
143 static void willRemoveNamedFlow(Document*, WebKitNamedFlow&);
144 static void didChangeRegionOverset(Document&, WebKitNamedFlow&);
145 static void didRegisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
146 static void didUnregisterNamedFlowContentElement(Document&, WebKitNamedFlow&, Node& contentElement);
148 static void mouseDidMoveOverElement(Page&, const HitTestResult&, unsigned modifierFlags);
149 static bool handleMousePress(Frame&);
150 static bool handleTouchEvent(Frame&, Node&);
151 static bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
153 static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
154 static void willFetch(ScriptExecutionContext&, const String& url);
155 static void didInstallTimer(ScriptExecutionContext&, int timerId, Seconds timeout, bool singleShot);
156 static void didRemoveTimer(ScriptExecutionContext&, int timerId);
158 static void didPostMessage(Frame&, TimerBase&, JSC::ExecState&);
159 static void didFailPostMessage(Frame&, TimerBase&);
160 static void willDispatchPostMessage(Frame&, TimerBase&);
161 static void didDispatchPostMessage(Frame&, TimerBase&);
163 static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine, int scriptColumn);
164 static void didCallFunction(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
165 static void didAddEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
166 static void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
167 static bool isEventListenerDisabled(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
168 static InspectorInstrumentationCookie willDispatchEvent(Document&, const Event&, bool hasEventListeners);
169 static void didDispatchEvent(const InspectorInstrumentationCookie&, bool defaultPrevented);
170 static void willHandleEvent(ScriptExecutionContext&, Event&, const RegisteredEventListener&);
171 static void didHandleEvent(ScriptExecutionContext&);
172 static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event&, DOMWindow&);
173 static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&, bool defaultPrevented);
174 static void eventDidResetAfterDispatch(const Event&);
175 static InspectorInstrumentationCookie willEvaluateScript(Frame&, const String& url, int lineNumber, int columnNumber);
176 static void didEvaluateScript(const InspectorInstrumentationCookie&, Frame&);
177 static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext&, int timerId, bool oneShot);
178 static void didFireTimer(const InspectorInstrumentationCookie&);
179 static void didInvalidateLayout(Frame&);
180 static InspectorInstrumentationCookie willLayout(Frame&);
181 static void didLayout(const InspectorInstrumentationCookie&, RenderObject&);
182 static void didScroll(Page&);
183 static void willComposite(Frame&);
184 static void didComposite(Frame&);
185 static void willPaint(RenderObject&);
186 static void didPaint(RenderObject&, const LayoutRect&);
187 static InspectorInstrumentationCookie willRecalculateStyle(Document&);
188 static void didRecalculateStyle(const InspectorInstrumentationCookie&);
189 static void didScheduleStyleRecalculation(Document&);
190 static void applyUserAgentOverride(Frame&, String&);
191 static void applyEmulatedMedia(Frame&, String&);
193 static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
194 static void didLoadResourceFromMemoryCache(Page&, DocumentLoader*, CachedResource*);
195 static void didReceiveResourceResponse(Frame&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
196 static void didReceiveThreadableLoaderResponse(DocumentThreadableLoader&, unsigned long identifier);
197 static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
198 static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, const NetworkLoadMetrics&, ResourceLoader*);
199 static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
201 static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
202 static void didReceiveResourceResponse(WorkerGlobalScope&, unsigned long identifier, const ResourceResponse&);
203 static void didReceiveData(WorkerGlobalScope&, unsigned long identifier, const char* data, int dataLength);
204 static void didFinishLoading(WorkerGlobalScope&, unsigned long identifier, const NetworkLoadMetrics&);
205 static void didFailLoading(WorkerGlobalScope&, unsigned long identifier, const ResourceError&);
207 // Some network requests do not go through the normal network loading path.
208 // These network requests have to issue their own willSendRequest / didReceiveResponse / didFinishLoading / didFailLoading
209 // instrumentation calls. Some of these loads are for resources that lack a CachedResource::Type.
210 enum class LoadType { Ping, Beacon };
211 static void willSendRequestOfType(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
213 static void continueAfterXFrameOptionsDenied(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
214 static void continueWithPolicyDownload(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
215 static void continueWithPolicyIgnore(Frame&, unsigned long identifier, DocumentLoader&, const ResourceResponse&);
216 static void willLoadXHRSynchronously(ScriptExecutionContext*);
217 static void didLoadXHRSynchronously(ScriptExecutionContext*);
218 static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString);
219 static void scriptExecutionBlockedByCSP(ScriptExecutionContext*, const String& directiveText);
220 static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier);
221 static void domContentLoadedEventFired(Frame&);
222 static void loadEventFired(Frame*);
223 static void frameDetachedFromParent(Frame&);
224 static void didCommitLoad(Frame&, DocumentLoader*);
225 static void frameDocumentUpdated(Frame&);
226 static void loaderDetachedFromFrame(Frame&, DocumentLoader&);
227 static void frameStartedLoading(Frame&);
228 static void frameStoppedLoading(Frame&);
229 static void frameScheduledNavigation(Frame&, Seconds delay);
230 static void frameClearedScheduledNavigation(Frame&);
231 static void defaultAppearanceDidChange(Page&, bool useDarkAppearance);
232 static void willDestroyCachedResource(CachedResource&);
234 static bool willInterceptRequest(const Frame*, const ResourceRequest&);
235 static bool shouldInterceptResponse(const Frame&, const ResourceResponse&);
236 static void interceptResponse(const Frame&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
238 static void addMessageToConsole(Page&, std::unique_ptr<Inspector::ConsoleMessage>);
239 static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>);
241 static void consoleCount(Page&, JSC::ExecState*, const String& label);
242 static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, const String& label);
243 static void consoleCountReset(Page&, JSC::ExecState*, const String& label);
244 static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, const String& label);
246 static void takeHeapSnapshot(Frame&, const String& title);
247 static void startConsoleTiming(Frame&, JSC::ExecState*, const String& label);
248 static void startConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
249 static void logConsoleTiming(Frame&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
250 static void logConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
251 static void stopConsoleTiming(Frame&, JSC::ExecState*, const String& label);
252 static void stopConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
253 static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
254 static void startProfiling(Page&, JSC::ExecState*, const String& title);
255 static void stopProfiling(Page&, JSC::ExecState*, const String& title);
256 static void consoleStartRecordingCanvas(CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
258 static void didRequestAnimationFrame(Document&, int callbackId);
259 static void didCancelAnimationFrame(Document&, int callbackId);
260 static InspectorInstrumentationCookie willFireAnimationFrame(Document&, int callbackId);
261 static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
263 static InspectorInstrumentationCookie willFireObserverCallback(ScriptExecutionContext&, const String& callbackType);
264 static void didFireObserverCallback(const InspectorInstrumentationCookie&);
266 static void didOpenDatabase(Database&);
268 static void didDispatchDOMStorageEvent(Page&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
270 static bool shouldWaitForDebuggerOnStart(ScriptExecutionContext&);
271 static void workerStarted(ScriptExecutionContext&, WorkerInspectorProxy*, const URL&);
272 static void workerTerminated(ScriptExecutionContext&, WorkerInspectorProxy*);
274 static void didCreateWebSocket(Document*, unsigned long identifier, const URL& requestURL);
275 static void willSendWebSocketHandshakeRequest(Document*, unsigned long identifier, const ResourceRequest&);
276 static void didReceiveWebSocketHandshakeResponse(Document*, unsigned long identifier, const ResourceResponse&);
277 static void didCloseWebSocket(Document*, unsigned long identifier);
278 static void didReceiveWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
279 static void didSendWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
280 static void didReceiveWebSocketFrameError(Document*, unsigned long identifier, const String& errorMessage);
282 #if ENABLE(RESOURCE_USAGE)
283 static void didHandleMemoryPressure(Page&, Critical);
286 static void didChangeCSSCanvasClientNodes(CanvasBase&);
287 static void didCreateCanvasRenderingContext(CanvasRenderingContext&);
288 static void didChangeCanvasMemory(CanvasRenderingContext&);
289 static void recordCanvasAction(CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
290 static void didFinishRecordingCanvasFrame(CanvasRenderingContext&, bool forceDispatch = false);
292 static void didEnableExtension(WebGLRenderingContextBase&, const String&);
293 static void didCreateWebGLProgram(WebGLRenderingContextBase&, WebGLProgram&);
294 static void willDestroyWebGLProgram(WebGLProgram&);
295 static bool isWebGLProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
296 static bool isWebGLProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
299 static void didCreateWebGPUDevice(WebGPUDevice&);
300 static void willDestroyWebGPUDevice(WebGPUDevice&);
301 static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
302 static void didCreateWebGPUPipeline(WebGPUDevice&, WebGPUPipeline&);
303 static void willDestroyWebGPUPipeline(WebGPUPipeline&);
306 static void networkStateChanged(Page&);
307 static void updateApplicationCacheStatus(Frame*);
309 static void layerTreeDidChange(Page*);
310 static void renderLayerDestroyed(Page*, const RenderLayer&);
312 static void frontendCreated();
313 static void frontendDeleted();
314 static bool hasFrontends() { return InspectorInstrumentationPublic::hasFrontends(); }
316 static void firstFrontendCreated();
317 static void lastFrontendDeleted();
319 static bool consoleAgentEnabled(ScriptExecutionContext*);
320 static bool timelineAgentTracking(ScriptExecutionContext*);
322 static InstrumentingAgents* instrumentingAgentsForPage(Page*);
324 static void registerInstrumentingAgents(InstrumentingAgents&);
325 static void unregisterInstrumentingAgents(InstrumentingAgents&);
328 static void didClearWindowObjectInWorldImpl(InstrumentingAgents&, Frame&, DOMWrapperWorld&);
329 static bool isDebuggerPausedImpl(InstrumentingAgents&);
331 static int identifierForNodeImpl(InstrumentingAgents&, Node&);
332 static void addEventListenersToNodeImpl(InstrumentingAgents&, Node&);
333 static void willInsertDOMNodeImpl(InstrumentingAgents&, Node& parent);
334 static void didInsertDOMNodeImpl(InstrumentingAgents&, Node&);
335 static void willRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
336 static void didRemoveDOMNodeImpl(InstrumentingAgents&, Node&);
337 static void willModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& oldValue, const AtomString& newValue);
338 static void didModifyDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name, const AtomString& value);
339 static void didRemoveDOMAttrImpl(InstrumentingAgents&, Element&, const AtomString& name);
340 static void characterDataModifiedImpl(InstrumentingAgents&, CharacterData&);
341 static void willInvalidateStyleAttrImpl(InstrumentingAgents&, Element&);
342 static void didInvalidateStyleAttrImpl(InstrumentingAgents&, Element&);
343 static void documentDetachedImpl(InstrumentingAgents&, Document&);
344 static void frameWindowDiscardedImpl(InstrumentingAgents&, DOMWindow*);
345 static void mediaQueryResultChangedImpl(InstrumentingAgents&);
346 static void activeStyleSheetsUpdatedImpl(InstrumentingAgents&, Document&);
347 static void didPushShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
348 static void willPopShadowRootImpl(InstrumentingAgents&, Element& host, ShadowRoot&);
349 static void didChangeCustomElementStateImpl(InstrumentingAgents&, Element&);
350 static void pseudoElementCreatedImpl(InstrumentingAgents&, PseudoElement&);
351 static void pseudoElementDestroyedImpl(InstrumentingAgents&, PseudoElement&);
352 static void didCreateNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
353 static void willRemoveNamedFlowImpl(InstrumentingAgents&, Document*, WebKitNamedFlow&);
354 static void didChangeRegionOversetImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&);
355 static void didRegisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement, Node* nextContentElement = nullptr);
356 static void didUnregisterNamedFlowContentElementImpl(InstrumentingAgents&, Document&, WebKitNamedFlow&, Node& contentElement);
358 static void mouseDidMoveOverElementImpl(InstrumentingAgents&, const HitTestResult&, unsigned modifierFlags);
359 static bool handleMousePressImpl(InstrumentingAgents&);
360 static bool handleTouchEventImpl(InstrumentingAgents&, Node&);
361 static bool forcePseudoStateImpl(InstrumentingAgents&, const Element&, CSSSelector::PseudoClassType);
363 static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
364 static void willFetchImpl(InstrumentingAgents&, const String& url);
365 static void didInstallTimerImpl(InstrumentingAgents&, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext&);
366 static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
368 static void didPostMessageImpl(InstrumentingAgents&, const TimerBase&, JSC::ExecState&);
369 static void didFailPostMessageImpl(InstrumentingAgents&, const TimerBase&);
370 static void willDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
371 static void didDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&);
373 static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, int scriptColumn, ScriptExecutionContext*);
374 static void didCallFunctionImpl(const InspectorInstrumentationCookie&, ScriptExecutionContext*);
375 static void didAddEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
376 static void willRemoveEventListenerImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
377 static bool isEventListenerDisabledImpl(InstrumentingAgents&, EventTarget&, const AtomString& eventType, EventListener&, bool capture);
378 static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents&, Document&, const Event&, bool hasEventListeners);
379 static void willHandleEventImpl(InstrumentingAgents&, Event&, const RegisteredEventListener&);
380 static void didHandleEventImpl(InstrumentingAgents&);
381 static void didDispatchEventImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
382 static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents&, const Event&, DOMWindow&);
383 static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&, bool defaultPrevented);
384 static void eventDidResetAfterDispatchImpl(InstrumentingAgents&, const Event&);
385 static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents&, Frame&, const String& url, int lineNumber, int columnNumber);
386 static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&, Frame&);
387 static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents&, int timerId, bool oneShot, ScriptExecutionContext&);
388 static void didFireTimerImpl(const InspectorInstrumentationCookie&);
389 static void didInvalidateLayoutImpl(InstrumentingAgents&, Frame&);
390 static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents&, Frame&);
391 static void didLayoutImpl(const InspectorInstrumentationCookie&, RenderObject&);
392 static void didScrollImpl(InstrumentingAgents&);
393 static void willCompositeImpl(InstrumentingAgents&, Frame&);
394 static void didCompositeImpl(InstrumentingAgents&);
395 static void willPaintImpl(InstrumentingAgents&, RenderObject&);
396 static void didPaintImpl(InstrumentingAgents&, RenderObject&, const LayoutRect&);
397 static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents&, Document&);
398 static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
399 static void didScheduleStyleRecalculationImpl(InstrumentingAgents&, Document&);
400 static void applyUserAgentOverrideImpl(InstrumentingAgents&, String&);
401 static void applyEmulatedMediaImpl(InstrumentingAgents&, String&);
403 static void willSendRequestImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
404 static void willSendRequestOfTypeImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, ResourceRequest&, LoadType);
405 static void markResourceAsCachedImpl(InstrumentingAgents&, unsigned long identifier);
406 static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents&, DocumentLoader*, CachedResource*);
407 static void didReceiveResourceResponseImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
408 static void didReceiveThreadableLoaderResponseImpl(InstrumentingAgents&, DocumentThreadableLoader&, unsigned long identifier);
409 static void didReceiveDataImpl(InstrumentingAgents&, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
410 static void didFinishLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const NetworkLoadMetrics&, ResourceLoader*);
411 static void didFailLoadingImpl(InstrumentingAgents&, unsigned long identifier, DocumentLoader*, const ResourceError&);
412 static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&);
413 static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&);
414 static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString);
415 static void scriptExecutionBlockedByCSPImpl(InstrumentingAgents&, const String& directiveText);
416 static void didReceiveScriptResponseImpl(InstrumentingAgents&, unsigned long identifier);
417 static void domContentLoadedEventFiredImpl(InstrumentingAgents&, Frame&);
418 static void loadEventFiredImpl(InstrumentingAgents&, Frame*);
419 static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&);
420 static void didCommitLoadImpl(InstrumentingAgents&, Frame&, DocumentLoader*);
421 static void frameDocumentUpdatedImpl(InstrumentingAgents&, Frame&);
422 static void loaderDetachedFromFrameImpl(InstrumentingAgents&, DocumentLoader&);
423 static void frameStartedLoadingImpl(InstrumentingAgents&, Frame&);
424 static void frameStoppedLoadingImpl(InstrumentingAgents&, Frame&);
425 static void frameScheduledNavigationImpl(InstrumentingAgents&, Frame&, Seconds delay);
426 static void frameClearedScheduledNavigationImpl(InstrumentingAgents&, Frame&);
427 static void defaultAppearanceDidChangeImpl(InstrumentingAgents&, bool useDarkAppearance);
428 static void willDestroyCachedResourceImpl(CachedResource&);
430 static bool willInterceptRequestImpl(InstrumentingAgents&, const ResourceRequest&);
431 static bool shouldInterceptResponseImpl(InstrumentingAgents&, const ResourceResponse&);
432 static void interceptResponseImpl(InstrumentingAgents&, const ResourceResponse&, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&&);
434 static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
436 static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
437 static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
438 static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
439 static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
440 static void startConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
441 static void logConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
442 static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
443 static void stopConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
444 static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
445 static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
446 static void stopProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
447 static void consoleStartRecordingCanvasImpl(InstrumentingAgents&, CanvasRenderingContext&, JSC::ExecState&, JSC::JSObject* options);
449 static void didRequestAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
450 static void didCancelAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
451 static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents&, int callbackId, Document&);
452 static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
454 static InspectorInstrumentationCookie willFireObserverCallbackImpl(InstrumentingAgents&, const String&, ScriptExecutionContext&);
455 static void didFireObserverCallbackImpl(const InspectorInstrumentationCookie&);
457 static void didOpenDatabaseImpl(InstrumentingAgents&, Database&);
459 static void didDispatchDOMStorageEventImpl(InstrumentingAgents&, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*);
461 static bool shouldWaitForDebuggerOnStartImpl(InstrumentingAgents&);
462 static void workerStartedImpl(InstrumentingAgents&, WorkerInspectorProxy*, const URL&);
463 static void workerTerminatedImpl(InstrumentingAgents&, WorkerInspectorProxy*);
465 static void didCreateWebSocketImpl(InstrumentingAgents&, unsigned long identifier, const URL& requestURL);
466 static void willSendWebSocketHandshakeRequestImpl(InstrumentingAgents&, unsigned long identifier, const ResourceRequest&);
467 static void didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents&, unsigned long identifier, const ResourceResponse&);
468 static void didCloseWebSocketImpl(InstrumentingAgents&, unsigned long identifier);
469 static void didReceiveWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
470 static void didSendWebSocketFrameImpl(InstrumentingAgents&, unsigned long identifier, const WebSocketFrame&);
471 static void didReceiveWebSocketFrameErrorImpl(InstrumentingAgents&, unsigned long identifier, const String&);
473 #if ENABLE(RESOURCE_USAGE)
474 static void didHandleMemoryPressureImpl(InstrumentingAgents&, Critical);
477 static void networkStateChangedImpl(InstrumentingAgents&);
478 static void updateApplicationCacheStatusImpl(InstrumentingAgents&, Frame&);
480 static void didChangeCSSCanvasClientNodesImpl(InstrumentingAgents&, CanvasBase&);
481 static void didCreateCanvasRenderingContextImpl(InstrumentingAgents&, CanvasRenderingContext&);
482 static void didChangeCanvasMemoryImpl(InstrumentingAgents&, CanvasRenderingContext&);
483 static void recordCanvasActionImpl(InstrumentingAgents&, CanvasRenderingContext&, const String&, std::initializer_list<RecordCanvasActionVariant>&& = { });
484 static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, CanvasRenderingContext&, bool forceDispatch = false);
486 static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
487 static void didCreateWebGLProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
488 static void willDestroyWebGLProgramImpl(InstrumentingAgents&, WebGLProgram&);
489 static bool isWebGLProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
490 static bool isWebGLProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
493 static void didCreateWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
494 static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
495 static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&);
496 static void didCreateWebGPUPipelineImpl(InstrumentingAgents&, WebGPUDevice&, WebGPUPipeline&);
497 static void willDestroyWebGPUPipelineImpl(InstrumentingAgents&, WebGPUPipeline&);
500 static void layerTreeDidChangeImpl(InstrumentingAgents&);
501 static void renderLayerDestroyedImpl(InstrumentingAgents&, const RenderLayer&);
503 static InstrumentingAgents& instrumentingAgentsForPage(Page&);
504 static InstrumentingAgents& instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope&);
506 static InstrumentingAgents* instrumentingAgentsForFrame(const Frame&);
507 static InstrumentingAgents* instrumentingAgentsForFrame(const Frame*);
508 static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext*);
509 static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext&);
510 static InstrumentingAgents* instrumentingAgentsForDocument(Document&);
511 static InstrumentingAgents* instrumentingAgentsForDocument(Document*);
512 static InstrumentingAgents* instrumentingAgentsForRenderer(RenderObject&);
513 static InstrumentingAgents* instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope*);
515 static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
518 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame& frame, DOMWrapperWorld& world)
520 FAST_RETURN_IF_NO_FRONTENDS(void());
521 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
522 didClearWindowObjectInWorldImpl(*instrumentingAgents, frame, world);
525 inline bool InspectorInstrumentation::isDebuggerPaused(Frame* frame)
527 FAST_RETURN_IF_NO_FRONTENDS(false);
528 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
529 return isDebuggerPausedImpl(*instrumentingAgents);
533 inline int InspectorInstrumentation::identifierForNode(Node& node)
535 FAST_RETURN_IF_NO_FRONTENDS(0);
536 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(node.document()))
537 return identifierForNodeImpl(*instrumentingAgents, node);
541 inline void InspectorInstrumentation::addEventListenersToNode(Node& node)
543 FAST_RETURN_IF_NO_FRONTENDS(void());
544 if (auto* instrumentingAgents = instrumentingAgentsForDocument(node.document()))
545 addEventListenersToNodeImpl(*instrumentingAgents, node);
548 inline void InspectorInstrumentation::willInsertDOMNode(Document& document, Node& parent)
550 FAST_RETURN_IF_NO_FRONTENDS(void());
551 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
552 willInsertDOMNodeImpl(*instrumentingAgents, parent);
555 inline void InspectorInstrumentation::didInsertDOMNode(Document& document, Node& node)
557 FAST_RETURN_IF_NO_FRONTENDS(void());
558 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
559 didInsertDOMNodeImpl(*instrumentingAgents, node);
562 inline void InspectorInstrumentation::willRemoveDOMNode(Document& document, Node& node)
564 FAST_RETURN_IF_NO_FRONTENDS(void());
565 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
566 willRemoveDOMNodeImpl(*instrumentingAgents, node);
569 inline void InspectorInstrumentation::didRemoveDOMNode(Document& document, Node& node)
571 FAST_RETURN_IF_NO_FRONTENDS(void());
572 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
573 didRemoveDOMNodeImpl(*instrumentingAgents, node);
576 inline void InspectorInstrumentation::willModifyDOMAttr(Document& document, Element& element, const AtomString& oldValue, const AtomString& newValue)
578 FAST_RETURN_IF_NO_FRONTENDS(void());
579 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
580 willModifyDOMAttrImpl(*instrumentingAgents, element, oldValue, newValue);
583 inline void InspectorInstrumentation::didModifyDOMAttr(Document& document, Element& element, const AtomString& name, const AtomString& value)
585 FAST_RETURN_IF_NO_FRONTENDS(void());
586 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
587 didModifyDOMAttrImpl(*instrumentingAgents, element, name, value);
590 inline void InspectorInstrumentation::didRemoveDOMAttr(Document& document, Element& element, const AtomString& name)
592 FAST_RETURN_IF_NO_FRONTENDS(void());
593 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
594 didRemoveDOMAttrImpl(*instrumentingAgents, element, name);
597 inline void InspectorInstrumentation::willInvalidateStyleAttr(Element& element)
599 FAST_RETURN_IF_NO_FRONTENDS(void());
600 if (auto* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
601 willInvalidateStyleAttrImpl(*instrumentingAgents, element);
604 inline void InspectorInstrumentation::didInvalidateStyleAttr(Element& element)
606 FAST_RETURN_IF_NO_FRONTENDS(void());
607 if (auto* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
608 didInvalidateStyleAttrImpl(*instrumentingAgents, element);
611 inline void InspectorInstrumentation::documentDetached(Document& document)
613 FAST_RETURN_IF_NO_FRONTENDS(void());
614 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
615 documentDetachedImpl(*instrumentingAgents, document);
618 inline void InspectorInstrumentation::frameWindowDiscarded(Frame& frame, DOMWindow* domWindow)
620 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
621 frameWindowDiscardedImpl(*instrumentingAgents, domWindow);
624 inline void InspectorInstrumentation::mediaQueryResultChanged(Document& document)
626 FAST_RETURN_IF_NO_FRONTENDS(void());
627 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
628 mediaQueryResultChangedImpl(*instrumentingAgents);
631 inline void InspectorInstrumentation::activeStyleSheetsUpdated(Document& document)
633 FAST_RETURN_IF_NO_FRONTENDS(void());
634 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
635 activeStyleSheetsUpdatedImpl(*instrumentingAgents, document);
638 inline void InspectorInstrumentation::didPushShadowRoot(Element& host, ShadowRoot& root)
640 FAST_RETURN_IF_NO_FRONTENDS(void());
641 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
642 didPushShadowRootImpl(*instrumentingAgents, host, root);
645 inline void InspectorInstrumentation::willPopShadowRoot(Element& host, ShadowRoot& root)
647 FAST_RETURN_IF_NO_FRONTENDS(void());
648 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host.document()))
649 willPopShadowRootImpl(*instrumentingAgents, host, root);
652 inline void InspectorInstrumentation::didChangeCustomElementState(Element& element)
654 FAST_RETURN_IF_NO_FRONTENDS(void());
655 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
656 didChangeCustomElementStateImpl(*instrumentingAgents, element);
659 inline void InspectorInstrumentation::pseudoElementCreated(Page* page, PseudoElement& pseudoElement)
661 FAST_RETURN_IF_NO_FRONTENDS(void());
662 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
663 pseudoElementCreatedImpl(*instrumentingAgents, pseudoElement);
666 inline void InspectorInstrumentation::pseudoElementDestroyed(Page* page, PseudoElement& pseudoElement)
668 FAST_RETURN_IF_NO_FRONTENDS(void());
669 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
670 pseudoElementDestroyedImpl(*instrumentingAgents, pseudoElement);
673 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
675 FAST_RETURN_IF_NO_FRONTENDS(void());
676 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
677 didCreateNamedFlowImpl(*instrumentingAgents, document, namedFlow);
680 inline void InspectorInstrumentation::willRemoveNamedFlow(Document* document, WebKitNamedFlow& namedFlow)
682 FAST_RETURN_IF_NO_FRONTENDS(void());
683 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
684 willRemoveNamedFlowImpl(*instrumentingAgents, document, namedFlow);
687 inline void InspectorInstrumentation::didChangeRegionOverset(Document& document, WebKitNamedFlow& namedFlow)
689 FAST_RETURN_IF_NO_FRONTENDS(void());
690 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
691 didChangeRegionOversetImpl(*instrumentingAgents, document, namedFlow);
694 inline void InspectorInstrumentation::didRegisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement, Node* nextContentElement)
696 FAST_RETURN_IF_NO_FRONTENDS(void());
697 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
698 didRegisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement, nextContentElement);
701 inline void InspectorInstrumentation::didUnregisterNamedFlowContentElement(Document& document, WebKitNamedFlow& namedFlow, Node& contentElement)
703 FAST_RETURN_IF_NO_FRONTENDS(void());
704 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
705 didUnregisterNamedFlowContentElementImpl(*instrumentingAgents, document, namedFlow, contentElement);
708 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page& page, const HitTestResult& result, unsigned modifierFlags)
710 FAST_RETURN_IF_NO_FRONTENDS(void());
711 mouseDidMoveOverElementImpl(instrumentingAgentsForPage(page), result, modifierFlags);
714 inline bool InspectorInstrumentation::handleTouchEvent(Frame& frame, Node& node)
716 FAST_RETURN_IF_NO_FRONTENDS(false);
717 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
718 return handleTouchEventImpl(*instrumentingAgents, node);
722 inline bool InspectorInstrumentation::handleMousePress(Frame& frame)
724 FAST_RETURN_IF_NO_FRONTENDS(false);
725 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
726 return handleMousePressImpl(*instrumentingAgents);
730 inline bool InspectorInstrumentation::forcePseudoState(const Element& element, CSSSelector::PseudoClassType pseudoState)
732 FAST_RETURN_IF_NO_FRONTENDS(false);
733 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element.document()))
734 return forcePseudoStateImpl(*instrumentingAgents, element, pseudoState);
738 inline void InspectorInstrumentation::characterDataModified(Document& document, CharacterData& characterData)
740 FAST_RETURN_IF_NO_FRONTENDS(void());
741 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
742 characterDataModifiedImpl(*instrumentingAgents, characterData);
745 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
747 FAST_RETURN_IF_NO_FRONTENDS(void());
748 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
749 willSendXMLHttpRequestImpl(*instrumentingAgents, url);
752 inline void InspectorInstrumentation::willFetch(ScriptExecutionContext& context, const String& url)
754 FAST_RETURN_IF_NO_FRONTENDS(void());
755 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
756 willFetchImpl(*instrumentingAgents, url);
759 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext& context, int timerId, Seconds timeout, bool singleShot)
761 FAST_RETURN_IF_NO_FRONTENDS(void());
762 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
763 didInstallTimerImpl(*instrumentingAgents, timerId, timeout, singleShot, context);
766 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext& context, int timerId)
768 FAST_RETURN_IF_NO_FRONTENDS(void());
769 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
770 didRemoveTimerImpl(*instrumentingAgents, timerId, context);
773 inline void InspectorInstrumentation::didAddEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
775 FAST_RETURN_IF_NO_FRONTENDS(void());
776 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
777 didAddEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
780 inline void InspectorInstrumentation::willRemoveEventListener(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
782 FAST_RETURN_IF_NO_FRONTENDS(void());
783 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
784 willRemoveEventListenerImpl(*instrumentingAgents, target, eventType, listener, capture);
787 inline bool InspectorInstrumentation::isEventListenerDisabled(EventTarget& target, const AtomString& eventType, EventListener& listener, bool capture)
789 FAST_RETURN_IF_NO_FRONTENDS(false);
790 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(target.scriptExecutionContext()))
791 return isEventListenerDisabledImpl(*instrumentingAgents, target, eventType, listener, capture);
795 inline void InspectorInstrumentation::didPostMessage(Frame& frame, TimerBase& timer, JSC::ExecState& state)
797 FAST_RETURN_IF_NO_FRONTENDS(void());
798 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
799 didPostMessageImpl(*instrumentingAgents, timer, state);
802 inline void InspectorInstrumentation::didFailPostMessage(Frame& frame, TimerBase& timer)
804 FAST_RETURN_IF_NO_FRONTENDS(void());
805 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
806 didFailPostMessageImpl(*instrumentingAgents, timer);
809 inline void InspectorInstrumentation::willDispatchPostMessage(Frame& frame, TimerBase& timer)
811 FAST_RETURN_IF_NO_FRONTENDS(void());
812 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
813 willDispatchPostMessageImpl(*instrumentingAgents, timer);
816 inline void InspectorInstrumentation::didDispatchPostMessage(Frame& frame, TimerBase& timer)
818 FAST_RETURN_IF_NO_FRONTENDS(void());
819 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
820 didDispatchPostMessageImpl(*instrumentingAgents, timer);
823 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine, int scriptColumn)
825 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
826 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
827 return willCallFunctionImpl(*instrumentingAgents, scriptName, scriptLine, scriptColumn, context);
828 return InspectorInstrumentationCookie();
831 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie, ScriptExecutionContext* context)
833 FAST_RETURN_IF_NO_FRONTENDS(void());
834 if (cookie.isValid())
835 didCallFunctionImpl(cookie, context);
838 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document& document, const Event& event, bool hasEventListeners)
840 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
841 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
842 return willDispatchEventImpl(*instrumentingAgents, document, event, hasEventListeners);
843 return InspectorInstrumentationCookie();
846 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
848 FAST_RETURN_IF_NO_FRONTENDS(void());
849 if (cookie.isValid())
850 didDispatchEventImpl(cookie, defaultPrevented);
853 inline void InspectorInstrumentation::willHandleEvent(ScriptExecutionContext& context, Event& event, const RegisteredEventListener& listener)
855 FAST_RETURN_IF_NO_FRONTENDS(void());
856 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
857 return willHandleEventImpl(*instrumentingAgents, event, listener);
860 inline void InspectorInstrumentation::didHandleEvent(ScriptExecutionContext& context)
862 FAST_RETURN_IF_NO_FRONTENDS(void());
863 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
864 return didHandleEventImpl(*instrumentingAgents);
867 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow& window)
869 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
870 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
871 return willDispatchEventOnWindowImpl(*instrumentingAgents, event, window);
872 return InspectorInstrumentationCookie();
875 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie, bool defaultPrevented)
877 FAST_RETURN_IF_NO_FRONTENDS(void());
878 if (cookie.isValid())
879 didDispatchEventOnWindowImpl(cookie, defaultPrevented);
882 inline void InspectorInstrumentation::eventDidResetAfterDispatch(const Event& event)
884 FAST_RETURN_IF_NO_FRONTENDS(void());
886 if (!is<Node>(event.target()))
889 auto* node = downcast<Node>(event.target());
890 if (auto* instrumentingAgents = instrumentingAgentsForContext(node->scriptExecutionContext()))
891 return eventDidResetAfterDispatchImpl(*instrumentingAgents, event);
894 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame& frame, const String& url, int lineNumber, int columnNumber)
896 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
897 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
898 return willEvaluateScriptImpl(*instrumentingAgents, frame, url, lineNumber, columnNumber);
899 return InspectorInstrumentationCookie();
902 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie, Frame& frame)
904 FAST_RETURN_IF_NO_FRONTENDS(void());
905 if (cookie.isValid())
906 didEvaluateScriptImpl(cookie, frame);
909 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext& context, int timerId, bool oneShot)
911 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
912 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
913 return willFireTimerImpl(*instrumentingAgents, timerId, oneShot, context);
914 return InspectorInstrumentationCookie();
917 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
919 FAST_RETURN_IF_NO_FRONTENDS(void());
920 if (cookie.isValid())
921 didFireTimerImpl(cookie);
924 inline void InspectorInstrumentation::didInvalidateLayout(Frame& frame)
926 FAST_RETURN_IF_NO_FRONTENDS(void());
927 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
928 didInvalidateLayoutImpl(*instrumentingAgents, frame);
931 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame& frame)
933 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
934 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
935 return willLayoutImpl(*instrumentingAgents, frame);
936 return InspectorInstrumentationCookie();
939 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie, RenderObject& root)
941 FAST_RETURN_IF_NO_FRONTENDS(void());
942 if (cookie.isValid())
943 didLayoutImpl(cookie, root);
946 inline void InspectorInstrumentation::didScroll(Page& page)
948 FAST_RETURN_IF_NO_FRONTENDS(void());
949 didScrollImpl(instrumentingAgentsForPage(page));
952 inline void InspectorInstrumentation::willComposite(Frame& frame)
954 FAST_RETURN_IF_NO_FRONTENDS(void());
955 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
956 willCompositeImpl(*instrumentingAgents, frame);
959 inline void InspectorInstrumentation::didComposite(Frame& frame)
961 FAST_RETURN_IF_NO_FRONTENDS(void());
962 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
963 didCompositeImpl(*instrumentingAgents);
966 inline void InspectorInstrumentation::willPaint(RenderObject& renderer)
968 FAST_RETURN_IF_NO_FRONTENDS(void());
969 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
970 return willPaintImpl(*instrumentingAgents, renderer);
973 inline void InspectorInstrumentation::didPaint(RenderObject& renderer, const LayoutRect& rect)
975 FAST_RETURN_IF_NO_FRONTENDS(void());
976 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
977 didPaintImpl(*instrumentingAgents, renderer, rect);
980 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document& document)
982 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
983 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
984 return willRecalculateStyleImpl(*instrumentingAgents, document);
985 return InspectorInstrumentationCookie();
988 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
990 FAST_RETURN_IF_NO_FRONTENDS(void());
991 if (cookie.isValid())
992 didRecalculateStyleImpl(cookie);
995 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document& document)
997 FAST_RETURN_IF_NO_FRONTENDS(void());
998 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
999 didScheduleStyleRecalculationImpl(*instrumentingAgents, document);
1002 inline void InspectorInstrumentation::applyUserAgentOverride(Frame& frame, String& userAgent)
1004 FAST_RETURN_IF_NO_FRONTENDS(void());
1005 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1006 applyUserAgentOverrideImpl(*instrumentingAgents, userAgent);
1009 inline void InspectorInstrumentation::applyEmulatedMedia(Frame& frame, String& media)
1011 FAST_RETURN_IF_NO_FRONTENDS(void());
1012 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1013 applyEmulatedMediaImpl(*instrumentingAgents, media);
1016 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
1018 FAST_RETURN_IF_NO_FRONTENDS(void());
1019 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1020 willSendRequestImpl(*instrumentingAgents, identifier, loader, request, redirectResponse);
1023 inline void InspectorInstrumentation::willSendRequest(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, ResourceRequest& request)
1025 FAST_RETURN_IF_NO_FRONTENDS(void());
1026 willSendRequestImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, request, ResourceResponse { });
1029 inline void InspectorInstrumentation::willSendRequestOfType(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, LoadType loadType)
1031 FAST_RETURN_IF_NO_FRONTENDS(void());
1032 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1033 willSendRequestOfTypeImpl(*instrumentingAgents, identifier, loader, request, loadType);
1036 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page& page, DocumentLoader* loader, CachedResource* resource)
1038 FAST_RETURN_IF_NO_FRONTENDS(void());
1039 didLoadResourceFromMemoryCacheImpl(instrumentingAgentsForPage(page), loader, resource);
1042 inline void InspectorInstrumentation::didReceiveResourceResponse(Frame& frame, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
1044 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1045 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, loader, response, resourceLoader);
1048 inline void InspectorInstrumentation::didReceiveResourceResponse(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceResponse& response)
1050 didReceiveResourceResponseImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, response, nullptr);
1053 inline void InspectorInstrumentation::didReceiveThreadableLoaderResponse(DocumentThreadableLoader& documentThreadableLoader, unsigned long identifier)
1055 FAST_RETURN_IF_NO_FRONTENDS(void());
1056 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(documentThreadableLoader.document()))
1057 didReceiveThreadableLoaderResponseImpl(*instrumentingAgents, documentThreadableLoader, identifier);
1060 inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
1062 FAST_RETURN_IF_NO_FRONTENDS(void());
1063 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1064 didReceiveDataImpl(*instrumentingAgents, identifier, data, dataLength, encodedDataLength);
1067 inline void InspectorInstrumentation::didReceiveData(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const char* data, int dataLength)
1069 FAST_RETURN_IF_NO_FRONTENDS(void());
1070 didReceiveDataImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, data, dataLength, dataLength);
1073 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics, ResourceLoader* resourceLoader)
1075 FAST_RETURN_IF_NO_FRONTENDS(void());
1076 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1077 didFinishLoadingImpl(*instrumentingAgents, identifier, loader, networkLoadMetrics, resourceLoader);
1080 inline void InspectorInstrumentation::didFinishLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const NetworkLoadMetrics& networkLoadMetrics)
1082 FAST_RETURN_IF_NO_FRONTENDS(void());
1083 didFinishLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, networkLoadMetrics, nullptr);
1086 inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
1088 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1089 didFailLoadingImpl(*instrumentingAgents, identifier, loader, error);
1092 inline void InspectorInstrumentation::didFailLoading(WorkerGlobalScope& workerGlobalScope, unsigned long identifier, const ResourceError& error)
1094 didFailLoadingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), identifier, nullptr, error);
1097 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1099 // Treat the same as didReceiveResponse.
1100 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1101 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1104 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1106 // Treat the same as didReceiveResponse.
1107 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1108 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1111 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame& frame, unsigned long identifier, DocumentLoader& loader, const ResourceResponse& response)
1113 // Treat the same as didReceiveResponse.
1114 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1115 didReceiveResourceResponseImpl(*instrumentingAgents, identifier, &loader, response, nullptr);
1118 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
1120 FAST_RETURN_IF_NO_FRONTENDS(void());
1121 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1122 willLoadXHRSynchronouslyImpl(*instrumentingAgents);
1125 inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionContext* context)
1127 FAST_RETURN_IF_NO_FRONTENDS(void());
1128 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1129 didLoadXHRSynchronouslyImpl(*instrumentingAgents);
1132 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext& context, unsigned long identifier, const String& sourceString)
1134 FAST_RETURN_IF_NO_FRONTENDS(void());
1135 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1136 scriptImportedImpl(*instrumentingAgents, identifier, sourceString);
1139 inline void InspectorInstrumentation::scriptExecutionBlockedByCSP(ScriptExecutionContext* context, const String& directiveText)
1141 FAST_RETURN_IF_NO_FRONTENDS(void());
1142 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1143 scriptExecutionBlockedByCSPImpl(*instrumentingAgents, directiveText);
1146 inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier)
1148 FAST_RETURN_IF_NO_FRONTENDS(void());
1149 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1150 didReceiveScriptResponseImpl(*instrumentingAgents, identifier);
1153 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame& frame)
1155 FAST_RETURN_IF_NO_FRONTENDS(void());
1156 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1157 domContentLoadedEventFiredImpl(*instrumentingAgents, frame);
1160 inline void InspectorInstrumentation::loadEventFired(Frame* frame)
1162 FAST_RETURN_IF_NO_FRONTENDS(void());
1163 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1164 loadEventFiredImpl(*instrumentingAgents, frame);
1167 inline void InspectorInstrumentation::frameDetachedFromParent(Frame& frame)
1169 FAST_RETURN_IF_NO_FRONTENDS(void());
1170 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1171 frameDetachedFromParentImpl(*instrumentingAgents, frame);
1174 inline void InspectorInstrumentation::didCommitLoad(Frame& frame, DocumentLoader* loader)
1176 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1177 didCommitLoadImpl(*instrumentingAgents, frame, loader);
1180 inline void InspectorInstrumentation::frameDocumentUpdated(Frame& frame)
1182 FAST_RETURN_IF_NO_FRONTENDS(void());
1183 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1184 frameDocumentUpdatedImpl(*instrumentingAgents, frame);
1187 inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame& frame, DocumentLoader& loader)
1189 FAST_RETURN_IF_NO_FRONTENDS(void());
1190 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1191 loaderDetachedFromFrameImpl(*instrumentingAgents, loader);
1194 inline void InspectorInstrumentation::frameStartedLoading(Frame& frame)
1196 FAST_RETURN_IF_NO_FRONTENDS(void());
1197 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1198 frameStartedLoadingImpl(*instrumentingAgents, frame);
1201 inline void InspectorInstrumentation::frameStoppedLoading(Frame& frame)
1203 FAST_RETURN_IF_NO_FRONTENDS(void());
1204 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1205 frameStoppedLoadingImpl(*instrumentingAgents, frame);
1208 inline void InspectorInstrumentation::frameScheduledNavigation(Frame& frame, Seconds delay)
1210 FAST_RETURN_IF_NO_FRONTENDS(void());
1211 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1212 frameScheduledNavigationImpl(*instrumentingAgents, frame, delay);
1215 inline void InspectorInstrumentation::frameClearedScheduledNavigation(Frame& frame)
1217 FAST_RETURN_IF_NO_FRONTENDS(void());
1218 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1219 frameClearedScheduledNavigationImpl(*instrumentingAgents, frame);
1222 inline void InspectorInstrumentation::defaultAppearanceDidChange(Page& page, bool useDarkAppearance)
1224 FAST_RETURN_IF_NO_FRONTENDS(void());
1225 defaultAppearanceDidChangeImpl(instrumentingAgentsForPage(page), useDarkAppearance);
1228 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource& cachedResource)
1230 FAST_RETURN_IF_NO_FRONTENDS(void());
1231 willDestroyCachedResourceImpl(cachedResource);
1234 inline bool InspectorInstrumentation::willInterceptRequest(const Frame* frame, const ResourceRequest& request)
1236 FAST_RETURN_IF_NO_FRONTENDS(false);
1237 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1238 return willInterceptRequestImpl(*instrumentingAgents, request);
1242 inline bool InspectorInstrumentation::shouldInterceptResponse(const Frame& frame, const ResourceResponse& response)
1244 ASSERT(InspectorInstrumentationPublic::hasFrontends());
1245 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1246 return shouldInterceptResponseImpl(*instrumentingAgents, response);
1250 inline void InspectorInstrumentation::interceptResponse(const Frame& frame, const ResourceResponse& response, unsigned long identifier, CompletionHandler<void(const ResourceResponse&, RefPtr<SharedBuffer>)>&& handler)
1252 ASSERT(InspectorInstrumentation::shouldInterceptResponse(frame, response));
1253 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1254 interceptResponseImpl(*instrumentingAgents, response, identifier, WTFMove(handler));
1257 inline void InspectorInstrumentation::didOpenDatabase(Database& database)
1259 FAST_RETURN_IF_NO_FRONTENDS(void());
1260 if (auto* instrumentingAgents = instrumentingAgentsForContext(database.document()))
1261 didOpenDatabaseImpl(*instrumentingAgents, database);
1264 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(Page& page, const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin)
1266 FAST_RETURN_IF_NO_FRONTENDS(void());
1267 didDispatchDOMStorageEventImpl(instrumentingAgentsForPage(page), key, oldValue, newValue, storageType, securityOrigin);
1270 inline bool InspectorInstrumentation::shouldWaitForDebuggerOnStart(ScriptExecutionContext& context)
1272 FAST_RETURN_IF_NO_FRONTENDS(false);
1273 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1274 return shouldWaitForDebuggerOnStartImpl(*instrumentingAgents);
1278 inline void InspectorInstrumentation::workerStarted(ScriptExecutionContext& context, WorkerInspectorProxy* proxy, const URL& url)
1280 FAST_RETURN_IF_NO_FRONTENDS(void());
1281 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1282 workerStartedImpl(*instrumentingAgents, proxy, url);
1285 inline void InspectorInstrumentation::workerTerminated(ScriptExecutionContext& context, WorkerInspectorProxy* proxy)
1287 FAST_RETURN_IF_NO_FRONTENDS(void());
1288 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1289 workerTerminatedImpl(*instrumentingAgents, proxy);
1292 inline void InspectorInstrumentation::didCreateWebSocket(Document* document, unsigned long identifier, const URL& requestURL)
1294 FAST_RETURN_IF_NO_FRONTENDS(void());
1295 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1296 didCreateWebSocketImpl(*instrumentingAgents, identifier, requestURL);
1299 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(Document* document, unsigned long identifier, const ResourceRequest& request)
1301 FAST_RETURN_IF_NO_FRONTENDS(void());
1302 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1303 willSendWebSocketHandshakeRequestImpl(*instrumentingAgents, identifier, request);
1306 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(Document* document, unsigned long identifier, const ResourceResponse& response)
1308 FAST_RETURN_IF_NO_FRONTENDS(void());
1309 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1310 didReceiveWebSocketHandshakeResponseImpl(*instrumentingAgents, identifier, response);
1313 inline void InspectorInstrumentation::didCloseWebSocket(Document* document, unsigned long identifier)
1315 FAST_RETURN_IF_NO_FRONTENDS(void());
1316 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1317 didCloseWebSocketImpl(*instrumentingAgents, identifier);
1320 inline void InspectorInstrumentation::didReceiveWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1322 FAST_RETURN_IF_NO_FRONTENDS(void());
1323 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1324 didReceiveWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1327 inline void InspectorInstrumentation::didReceiveWebSocketFrameError(Document* document, unsigned long identifier, const String& errorMessage)
1329 FAST_RETURN_IF_NO_FRONTENDS(void());
1330 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1331 didReceiveWebSocketFrameErrorImpl(*instrumentingAgents, identifier, errorMessage);
1334 inline void InspectorInstrumentation::didSendWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1336 FAST_RETURN_IF_NO_FRONTENDS(void());
1337 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1338 didSendWebSocketFrameImpl(*instrumentingAgents, identifier, frame);
1341 #if ENABLE(RESOURCE_USAGE)
1342 inline void InspectorInstrumentation::didHandleMemoryPressure(Page& page, Critical critical)
1344 FAST_RETURN_IF_NO_FRONTENDS(void());
1345 didHandleMemoryPressureImpl(instrumentingAgentsForPage(page), critical);
1349 inline void InspectorInstrumentation::didChangeCSSCanvasClientNodes(CanvasBase& canvasBase)
1351 FAST_RETURN_IF_NO_FRONTENDS(void());
1352 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(canvasBase.scriptExecutionContext()))
1353 didChangeCSSCanvasClientNodesImpl(*instrumentingAgents, canvasBase);
1356 inline void InspectorInstrumentation::didCreateCanvasRenderingContext(CanvasRenderingContext& context)
1358 FAST_RETURN_IF_NO_FRONTENDS(void());
1359 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1360 didCreateCanvasRenderingContextImpl(*instrumentingAgents, context);
1363 inline void InspectorInstrumentation::didChangeCanvasMemory(CanvasRenderingContext& context)
1365 FAST_RETURN_IF_NO_FRONTENDS(void());
1366 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1367 didChangeCanvasMemoryImpl(*instrumentingAgents, context);
1370 inline void InspectorInstrumentation::recordCanvasAction(CanvasRenderingContext& context, const String& name, std::initializer_list<RecordCanvasActionVariant>&& parameters)
1372 FAST_RETURN_IF_NO_FRONTENDS(void());
1373 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1374 recordCanvasActionImpl(*instrumentingAgents, context, name, WTFMove(parameters));
1377 inline void InspectorInstrumentation::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch)
1379 FAST_RETURN_IF_NO_FRONTENDS(void());
1380 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1381 didFinishRecordingCanvasFrameImpl(*instrumentingAgents, context, forceDispatch);
1385 inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& contextWebGLBase, const String& extension)
1387 FAST_RETURN_IF_NO_FRONTENDS(void());
1388 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1389 didEnableExtensionImpl(*instrumentingAgents, contextWebGLBase, extension);
1392 inline void InspectorInstrumentation::didCreateWebGLProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1394 FAST_RETURN_IF_NO_FRONTENDS(void());
1395 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1396 didCreateWebGLProgramImpl(*instrumentingAgents, contextWebGLBase, program);
1399 inline void InspectorInstrumentation::willDestroyWebGLProgram(WebGLProgram& program)
1401 FAST_RETURN_IF_NO_FRONTENDS(void());
1402 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(program.scriptExecutionContext()))
1403 willDestroyWebGLProgramImpl(*instrumentingAgents, program);
1406 inline bool InspectorInstrumentation::isWebGLProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1408 FAST_RETURN_IF_NO_FRONTENDS(false);
1409 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1410 return isWebGLProgramDisabledImpl(*instrumentingAgents, program);
1414 inline bool InspectorInstrumentation::isWebGLProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
1416 FAST_RETURN_IF_NO_FRONTENDS(false);
1417 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
1418 return isWebGLProgramHighlightedImpl(*instrumentingAgents, program);
1424 inline void InspectorInstrumentation::didCreateWebGPUDevice(WebGPUDevice& device)
1426 FAST_RETURN_IF_NO_FRONTENDS(void());
1427 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1428 didCreateWebGPUDeviceImpl(*instrumentingAgents, device);
1431 inline void InspectorInstrumentation::willDestroyWebGPUDevice(WebGPUDevice& device)
1433 FAST_RETURN_IF_NO_FRONTENDS(void());
1434 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1435 willDestroyWebGPUDeviceImpl(*instrumentingAgents, device);
1438 inline void InspectorInstrumentation::willConfigureSwapChain(GPUCanvasContext& contextGPU, WebGPUSwapChain& newSwapChain)
1440 FAST_RETURN_IF_NO_FRONTENDS(void());
1441 if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext()))
1442 willConfigureSwapChainImpl(*instrumentingAgents, contextGPU, newSwapChain);
1445 inline void InspectorInstrumentation::didCreateWebGPUPipeline(WebGPUDevice& device, WebGPUPipeline& pipeline)
1447 FAST_RETURN_IF_NO_FRONTENDS(void());
1448 if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
1449 didCreateWebGPUPipelineImpl(*instrumentingAgents, device, pipeline);
1452 inline void InspectorInstrumentation::willDestroyWebGPUPipeline(WebGPUPipeline& pipeline)
1454 FAST_RETURN_IF_NO_FRONTENDS(void());
1455 if (auto* instrumentingAgents = instrumentingAgentsForContext(pipeline.scriptExecutionContext()))
1456 willDestroyWebGPUPipelineImpl(*instrumentingAgents, pipeline);
1460 inline void InspectorInstrumentation::networkStateChanged(Page& page)
1462 FAST_RETURN_IF_NO_FRONTENDS(void());
1463 networkStateChangedImpl(instrumentingAgentsForPage(page));
1466 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
1468 FAST_RETURN_IF_NO_FRONTENDS(void());
1469 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1470 updateApplicationCacheStatusImpl(*instrumentingAgents, *frame);
1473 inline void InspectorInstrumentation::addMessageToConsole(Page& page, std::unique_ptr<Inspector::ConsoleMessage> message)
1475 addMessageToConsoleImpl(instrumentingAgentsForPage(page), WTFMove(message));
1478 inline void InspectorInstrumentation::addMessageToConsole(WorkerGlobalScope& workerGlobalScope, std::unique_ptr<Inspector::ConsoleMessage> message)
1480 addMessageToConsoleImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), WTFMove(message));
1483 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, const String& label)
1485 consoleCountImpl(instrumentingAgentsForPage(page), state, label);
1488 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
1490 consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
1493 inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, const String& label)
1495 consoleCountResetImpl(instrumentingAgentsForPage(page), state, label);
1498 inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
1500 consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
1503 inline void InspectorInstrumentation::takeHeapSnapshot(Frame& frame, const String& title)
1505 FAST_RETURN_IF_NO_FRONTENDS(void());
1506 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1507 takeHeapSnapshotImpl(*instrumentingAgents, title);
1510 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
1512 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1513 startConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
1516 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
1518 startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
1521 inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
1523 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1524 logConsoleTimingImpl(*instrumentingAgents, exec, label, WTFMove(arguments));
1527 inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
1529 logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label, WTFMove(arguments));
1532 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
1534 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
1535 stopConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
1538 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
1540 stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
1543 inline void InspectorInstrumentation::consoleTimeStamp(Frame& frame, Ref<Inspector::ScriptArguments>&& arguments)
1545 FAST_RETURN_IF_NO_FRONTENDS(void());
1546 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1547 consoleTimeStampImpl(*instrumentingAgents, frame, WTFMove(arguments));
1550 inline void InspectorInstrumentation::startProfiling(Page& page, JSC::ExecState* exec, const String &title)
1552 FAST_RETURN_IF_NO_FRONTENDS(void());
1553 startProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1556 inline void InspectorInstrumentation::stopProfiling(Page& page, JSC::ExecState* exec, const String &title)
1558 FAST_RETURN_IF_NO_FRONTENDS(void());
1559 stopProfilingImpl(instrumentingAgentsForPage(page), exec, title);
1562 inline void InspectorInstrumentation::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options)
1564 FAST_RETURN_IF_NO_FRONTENDS(void());
1565 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context.canvasBase().scriptExecutionContext()))
1566 consoleStartRecordingCanvasImpl(*instrumentingAgents, context, exec, options);
1569 inline void InspectorInstrumentation::didRequestAnimationFrame(Document& document, int callbackId)
1571 FAST_RETURN_IF_NO_FRONTENDS(void());
1572 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1573 didRequestAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1576 inline void InspectorInstrumentation::didCancelAnimationFrame(Document& document, int callbackId)
1578 FAST_RETURN_IF_NO_FRONTENDS(void());
1579 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1580 didCancelAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1583 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document& document, int callbackId)
1585 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1586 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1587 return willFireAnimationFrameImpl(*instrumentingAgents, callbackId, document);
1588 return InspectorInstrumentationCookie();
1591 inline void InspectorInstrumentation::didFireAnimationFrame(const InspectorInstrumentationCookie& cookie)
1593 FAST_RETURN_IF_NO_FRONTENDS(void());
1594 if (cookie.isValid())
1595 didFireAnimationFrameImpl(cookie);
1598 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireObserverCallback(ScriptExecutionContext& context, const String& callbackType)
1600 FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1601 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1602 return willFireObserverCallbackImpl(*instrumentingAgents, callbackType, context);
1603 return InspectorInstrumentationCookie();
1606 inline void InspectorInstrumentation::didFireObserverCallback(const InspectorInstrumentationCookie& cookie)
1608 FAST_RETURN_IF_NO_FRONTENDS(void());
1609 if (cookie.isValid())
1610 didFireObserverCallbackImpl(cookie);
1613 inline void InspectorInstrumentation::layerTreeDidChange(Page* page)
1615 FAST_RETURN_IF_NO_FRONTENDS(void());
1616 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1617 layerTreeDidChangeImpl(*instrumentingAgents);
1620 inline void InspectorInstrumentation::renderLayerDestroyed(Page* page, const RenderLayer& renderLayer)
1622 FAST_RETURN_IF_NO_FRONTENDS(void());
1623 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1624 renderLayerDestroyedImpl(*instrumentingAgents, renderLayer);
1627 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
1629 return context ? instrumentingAgentsForContext(*context) : nullptr;
1632 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext& context)
1634 if (is<Document>(context))
1635 return instrumentingAgentsForPage(downcast<Document>(context).page());
1636 if (is<WorkerGlobalScope>(context))
1637 return &instrumentingAgentsForWorkerGlobalScope(downcast<WorkerGlobalScope>(context));
1641 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(const Frame* frame)
1643 return frame ? instrumentingAgentsForFrame(*frame) : nullptr;
1646 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(const Frame& frame)
1648 return instrumentingAgentsForPage(frame.page());
1651 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document* document)
1653 return document ? instrumentingAgentsForDocument(*document) : nullptr;
1656 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document& document)
1658 Page* page = document.page();
1659 if (!page && document.templateDocumentHost())
1660 page = document.templateDocumentHost()->page();
1661 return instrumentingAgentsForPage(page);
1664 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
1666 return page ? &instrumentingAgentsForPage(*page) : nullptr;
1669 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForPage(Page& page)
1671 ASSERT(isMainThread());
1672 return page.inspectorController().m_instrumentingAgents.get();
1675 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
1677 return workerGlobalScope ? &instrumentingAgentsForWorkerGlobalScope(*workerGlobalScope) : nullptr;
1680 inline InstrumentingAgents& InspectorInstrumentation::instrumentingAgentsForWorkerGlobalScope(WorkerGlobalScope& workerGlobalScope)
1682 return workerGlobalScope.inspectorController().m_instrumentingAgents;
1685 inline void InspectorInstrumentation::frontendCreated()
1687 ASSERT(isMainThread());
1688 ++InspectorInstrumentationPublic::s_frontendCounter;
1690 if (InspectorInstrumentationPublic::s_frontendCounter == 1)
1691 InspectorInstrumentation::firstFrontendCreated();
1694 inline void InspectorInstrumentation::frontendDeleted()
1696 ASSERT(isMainThread());
1697 --InspectorInstrumentationPublic::s_frontendCounter;
1699 if (!InspectorInstrumentationPublic::s_frontendCounter)
1700 InspectorInstrumentation::lastFrontendDeleted();
1703 } // namespace WebCore