Web Inspector: render box model elements and grid on inspector overlay
[WebKit-https.git] / Source / WebCore / inspector / InspectorInstrumentation.h
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef InspectorInstrumentation_h
32 #define InspectorInstrumentation_h
33
34 #include "CSSSelector.h"
35 #include "ConsoleTypes.h"
36 #include "Document.h"
37 #include "Element.h"
38 #include "Frame.h"
39 #include "Page.h"
40 #include "ScriptExecutionContext.h"
41 #include "StorageArea.h"
42
43 #if USE(JSC)
44 namespace JSC {
45 class ExecState;
46 }
47 #endif
48
49 namespace WebCore {
50
51 class CSSRule;
52 class CharacterData;
53 class DOMWindow;
54 class DOMWrapperWorld;
55 class Database;
56 class Element;
57 class EventContext;
58 class DocumentLoader;
59 class DeviceOrientationData;
60 class GeolocationPosition;
61 class GraphicsContext;
62 class HitTestResult;
63 class InspectorCSSAgent;
64 class InspectorTimelineAgent;
65 class InstrumentingAgents;
66 class KURL;
67 class Node;
68 class ResourceRequest;
69 class ResourceResponse;
70 class ScriptArguments;
71 class ScriptCallStack;
72 class ScriptExecutionContext;
73 class ScriptObject;
74 class ScriptProfile;
75 class SecurityOrigin;
76 class ShadowRoot;
77 class StorageArea;
78 class StyleRule;
79 class WorkerContext;
80 class WorkerContextProxy;
81 class XMLHttpRequest;
82
83 #if USE(JSC)
84 typedef JSC::ExecState ScriptState;
85 #else
86 class ScriptState;
87 #endif
88
89 #if ENABLE(WEB_SOCKETS)
90 struct WebSocketFrame;
91 class WebSocketHandshakeRequest;
92 class WebSocketHandshakeResponse;
93 #endif
94
95 #define FAST_RETURN_IF_NO_FRONTENDS(value) if (!hasFrontends()) return value;
96
97 typedef pair<InstrumentingAgents*, int> InspectorInstrumentationCookie;
98
99 class InspectorInstrumentation {
100 public:
101     static void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
102     static bool isDebuggerPaused(Frame*);
103
104     static void willInsertDOMNode(Document*, Node* parent);
105     static void didInsertDOMNode(Document*, Node*);
106     static void willRemoveDOMNode(Document*, Node*);
107     static void willModifyDOMAttr(Document*, Element*, const AtomicString& oldValue, const AtomicString& newValue);
108     static void didModifyDOMAttr(Document*, Element*, const AtomicString& name, const AtomicString& value);
109     static void didRemoveDOMAttr(Document*, Element*, const AtomicString& name);
110     static void characterDataModified(Document*, CharacterData*);
111     static void didInvalidateStyleAttr(Document*, Node*);
112     static void frameWindowDiscarded(Frame*, DOMWindow*);
113     static void mediaQueryResultChanged(Document*);
114     static void didPushShadowRoot(Element* host, ShadowRoot*);
115     static void willPopShadowRoot(Element* host, ShadowRoot*);
116     static void didCreateNamedFlow(Document*, const AtomicString& name);
117     static void didRemoveNamedFlow(Document*, const AtomicString& name);
118
119     static void mouseDidMoveOverElement(Page*, const HitTestResult&, unsigned modifierFlags);
120     static bool handleMousePress(Page*);
121     static bool forcePseudoState(Element*, CSSSelector::PseudoType);
122
123     static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
124     static void didScheduleResourceRequest(Document*, const String& url);
125     static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
126     static void didRemoveTimer(ScriptExecutionContext*, int timerId);
127
128     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
129     static void didCallFunction(const InspectorInstrumentationCookie&);
130     static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request);
131     static void didChangeXHRReadyState(const InspectorInstrumentationCookie&);
132     static InspectorInstrumentationCookie willDispatchEvent(Document*, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors);
133     static void didDispatchEvent(const InspectorInstrumentationCookie&);
134     static InspectorInstrumentationCookie willHandleEvent(ScriptExecutionContext*, Event*);
135     static void didHandleEvent(const InspectorInstrumentationCookie&);
136     static InspectorInstrumentationCookie willDispatchEventOnWindow(Frame*, const Event& event, DOMWindow* window);
137     static void didDispatchEventOnWindow(const InspectorInstrumentationCookie&);
138     static InspectorInstrumentationCookie willEvaluateScript(Frame*, const String& url, int lineNumber);
139     static void didEvaluateScript(const InspectorInstrumentationCookie&);
140     static void didCreateIsolatedContext(Frame*, ScriptState*, SecurityOrigin*);
141     static InspectorInstrumentationCookie willFireTimer(ScriptExecutionContext*, int timerId);
142     static void didFireTimer(const InspectorInstrumentationCookie&);
143     static void didBeginFrame(Page*);
144     static void didCancelFrame(Page*);
145     static void didInvalidateLayout(Frame*);
146     static InspectorInstrumentationCookie willLayout(Frame*);
147     static void didLayout(const InspectorInstrumentationCookie&);
148     static void didScroll(Page*);
149     static InspectorInstrumentationCookie willLoadXHR(ScriptExecutionContext*, XMLHttpRequest*);
150     static void didLoadXHR(const InspectorInstrumentationCookie&);
151     static InspectorInstrumentationCookie willPaint(Frame*, GraphicsContext*, const LayoutRect&);
152     static void didPaint(const InspectorInstrumentationCookie&);
153     static void willComposite(Page*);
154     static void didComposite(Page*);
155     static InspectorInstrumentationCookie willRecalculateStyle(Document*);
156     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
157     static void didScheduleStyleRecalculation(Document*);
158     static InspectorInstrumentationCookie willMatchRule(Document*, const StyleRule*);
159     static void didMatchRule(const InspectorInstrumentationCookie&, bool matched);
160     static InspectorInstrumentationCookie willProcessRule(Document*, const StyleRule*);
161     static void didProcessRule(const InspectorInstrumentationCookie&);
162     static void willProcessTask(Page*);
163     static void didProcessTask(Page*);
164
165     static void applyUserAgentOverride(Frame*, String*);
166     static void applyScreenWidthOverride(Frame*, long*);
167     static void applyScreenHeightOverride(Frame*, long*);
168     static bool shouldApplyScreenWidthOverride(Frame*);
169     static bool shouldApplyScreenHeightOverride(Frame*);
170     static void willSendRequest(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
171     static void continueAfterPingLoader(Frame*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
172     static void markResourceAsCached(Page*, unsigned long identifier);
173     static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, CachedResource*);
174     static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier, int length);
175     static void didReceiveResourceData(const InspectorInstrumentationCookie&);
176     static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse&);
177     static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
178     static void continueAfterXFrameOptionsDenied(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
179     static void continueWithPolicyDownload(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
180     static void continueWithPolicyIgnore(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
181     static void didReceiveData(Frame*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
182     static void didFinishLoading(Frame*, DocumentLoader*, unsigned long identifier, double finishTime);
183     static void didFailLoading(Frame*, DocumentLoader*, unsigned long identifier, const ResourceError&);
184     static void resourceRetrievedByXMLHttpRequest(ScriptExecutionContext*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
185     static void didReceiveXHRResponse(ScriptExecutionContext*, unsigned long identifier);
186     static void willLoadXHRSynchronously(ScriptExecutionContext*);
187     static void didLoadXHRSynchronously(ScriptExecutionContext*);
188     static void scriptImported(ScriptExecutionContext*, unsigned long identifier, const String& sourceString);
189     static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier);
190     static void domContentLoadedEventFired(Frame*);
191     static void loadEventFired(Frame*);
192     static void frameDetachedFromParent(Frame*);
193     static void didCommitLoad(Frame*, DocumentLoader*);
194     static void loaderDetachedFromFrame(Frame*, DocumentLoader*);
195     static void willDestroyCachedResource(CachedResource*);
196
197     static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
198     static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine);
199
200     static void addMessageToConsole(Page*, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
201     static void addMessageToConsole(Page*, MessageSource, MessageType, MessageLevel, const String& message, const String&, unsigned lineNumber);
202 #if ENABLE(WORKERS)
203     static void addMessageToConsole(WorkerContext*, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
204     static void addMessageToConsole(WorkerContext*, MessageSource, MessageType, MessageLevel, const String& message, const String&, unsigned lineNumber);
205 #endif
206     static void consoleCount(Page*, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
207     static void startConsoleTiming(Frame*, const String& title);
208     static void stopConsoleTiming(Frame*, const String& title, PassRefPtr<ScriptCallStack>);
209     static void consoleTimeStamp(Frame*, PassRefPtr<ScriptArguments>);
210
211     static void didRequestAnimationFrame(Document*, int callbackId);
212     static void didCancelAnimationFrame(Document*, int callbackId);
213     static InspectorInstrumentationCookie willFireAnimationFrame(Document*, int callbackId);
214     static void didFireAnimationFrame(const InspectorInstrumentationCookie&);
215
216 #if ENABLE(JAVASCRIPT_DEBUGGER)
217     static void addStartProfilingMessageToConsole(Page*, const String& title, unsigned lineNumber, const String& sourceURL);
218     static void addProfile(Page*, RefPtr<ScriptProfile>, PassRefPtr<ScriptCallStack>);
219     static String getCurrentUserInitiatedProfileName(Page*, bool incrementProfileNumber);
220     static bool profilerEnabled(Page*);
221 #endif
222
223 #if ENABLE(SQL_DATABASE)
224     static void didOpenDatabase(ScriptExecutionContext*, PassRefPtr<Database>, const String& domain, const String& name, const String& version);
225 #endif
226
227     static void didUseDOMStorage(Page*, StorageArea*, bool isLocalStorage, Frame*);
228     static void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*);
229
230 #if ENABLE(WORKERS)
231     static bool shouldPauseDedicatedWorkerOnStart(ScriptExecutionContext*);
232     static void didStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy*, const KURL&);
233     static void workerContextTerminated(ScriptExecutionContext*, WorkerContextProxy*);
234     static void willEvaluateWorkerScript(WorkerContext*, int workerThreadStartMode);
235 #endif
236
237 #if ENABLE(WEB_SOCKETS)
238     static void didCreateWebSocket(ScriptExecutionContext*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL);
239     static void willSendWebSocketHandshakeRequest(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeRequest&);
240     static void didReceiveWebSocketHandshakeResponse(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeResponse&);
241     static void didCloseWebSocket(ScriptExecutionContext*, unsigned long identifier);
242     static void didReceiveWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
243     static void didSendWebSocketFrame(Document*, unsigned long identifier, const WebSocketFrame&);
244     static void didReceiveWebSocketFrameError(Document*, unsigned long identifier, const String& errorMessage);
245 #endif
246
247 #if ENABLE(WEBGL)
248     static ScriptObject wrapWebGLRenderingContextForInstrumentation(Document*, const ScriptObject&);
249 #endif
250
251     static void networkStateChanged(Page*);
252     static void updateApplicationCacheStatus(Frame*);
253
254 #if ENABLE(INSPECTOR)
255     static void frontendCreated() { s_frontendCounter += 1; }
256     static void frontendDeleted() { s_frontendCounter -= 1; }
257     static bool hasFrontends() { return s_frontendCounter; }
258     static bool hasFrontendForScriptContext(ScriptExecutionContext*);
259     static bool collectingHTMLParseErrors(Page*);
260 #else
261     static bool hasFrontends() { return false; }
262     static bool hasFrontendForScriptContext(ScriptExecutionContext*) { return false; }
263     static bool collectingHTMLParseErrors(Page*) { return false; }
264 #endif
265
266 #if ENABLE(GEOLOCATION)
267     static GeolocationPosition* overrideGeolocationPosition(Page*, GeolocationPosition*);
268 #endif
269
270     static void registerInstrumentingAgents(InstrumentingAgents*);
271     static void unregisterInstrumentingAgents(InstrumentingAgents*);
272
273     static DeviceOrientationData* overrideDeviceOrientation(Page*, DeviceOrientationData*);
274
275 private:
276 #if ENABLE(INSPECTOR)
277     static void didClearWindowObjectInWorldImpl(InstrumentingAgents*, Frame*, DOMWrapperWorld*);
278     static bool isDebuggerPausedImpl(InstrumentingAgents*);
279
280     static void willInsertDOMNodeImpl(InstrumentingAgents*, Node* parent);
281     static void didInsertDOMNodeImpl(InstrumentingAgents*, Node*);
282     static void willRemoveDOMNodeImpl(InstrumentingAgents*, Node*);
283     static void didRemoveDOMNodeImpl(InstrumentingAgents*, Node*);
284     static void willModifyDOMAttrImpl(InstrumentingAgents*, Element*, const AtomicString& oldValue, const AtomicString& newValue);
285     static void didModifyDOMAttrImpl(InstrumentingAgents*, Element*, const AtomicString& name, const AtomicString& value);
286     static void didRemoveDOMAttrImpl(InstrumentingAgents*, Element*, const AtomicString& name);
287     static void characterDataModifiedImpl(InstrumentingAgents*, CharacterData*);
288     static void didInvalidateStyleAttrImpl(InstrumentingAgents*, Node*);
289     static void frameWindowDiscardedImpl(InstrumentingAgents*, DOMWindow*);
290     static void mediaQueryResultChangedImpl(InstrumentingAgents*);
291     static void didPushShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
292     static void willPopShadowRootImpl(InstrumentingAgents*, Element* host, ShadowRoot*);
293     static void didCreateNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
294     static void didRemoveNamedFlowImpl(InstrumentingAgents*, Document*, const AtomicString& name);
295
296     static void mouseDidMoveOverElementImpl(InstrumentingAgents*, const HitTestResult&, unsigned modifierFlags);
297     static bool handleMousePressImpl(InstrumentingAgents*);
298     static bool forcePseudoStateImpl(InstrumentingAgents*, Element*, CSSSelector::PseudoType);
299
300     static void willSendXMLHttpRequestImpl(InstrumentingAgents*, const String& url);
301     static void didScheduleResourceRequestImpl(InstrumentingAgents*, const String& url, Frame*);
302     static void didInstallTimerImpl(InstrumentingAgents*, int timerId, int timeout, bool singleShot, ScriptExecutionContext*);
303     static void didRemoveTimerImpl(InstrumentingAgents*, int timerId, ScriptExecutionContext*);
304
305     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents*, const String& scriptName, int scriptLine, ScriptExecutionContext*);
306     static void didCallFunctionImpl(const InspectorInstrumentationCookie&);
307     static InspectorInstrumentationCookie willChangeXHRReadyStateImpl(InstrumentingAgents*, XMLHttpRequest*, ScriptExecutionContext*);
308     static void didChangeXHRReadyStateImpl(const InspectorInstrumentationCookie&);
309     static InspectorInstrumentationCookie willDispatchEventImpl(InstrumentingAgents*, const Event&, DOMWindow*, Node*, const Vector<EventContext>& ancestors, Document*);
310     static InspectorInstrumentationCookie willHandleEventImpl(InstrumentingAgents*, Event*);
311     static void didHandleEventImpl(const InspectorInstrumentationCookie&);
312     static void didDispatchEventImpl(const InspectorInstrumentationCookie&);
313     static InspectorInstrumentationCookie willDispatchEventOnWindowImpl(InstrumentingAgents*, const Event&, DOMWindow*);
314     static void didDispatchEventOnWindowImpl(const InspectorInstrumentationCookie&);
315     static InspectorInstrumentationCookie willEvaluateScriptImpl(InstrumentingAgents*, const String& url, int lineNumber, Frame*);
316     static void didEvaluateScriptImpl(const InspectorInstrumentationCookie&);
317     static void didCreateIsolatedContextImpl(InstrumentingAgents*, Frame*, ScriptState*, SecurityOrigin*);
318     static InspectorInstrumentationCookie willFireTimerImpl(InstrumentingAgents*, int timerId, ScriptExecutionContext*);
319     static void didFireTimerImpl(const InspectorInstrumentationCookie&);
320     static void didBeginFrameImpl(InstrumentingAgents*);
321     static void didCancelFrameImpl(InstrumentingAgents*);
322     static void didInvalidateLayoutImpl(InstrumentingAgents*, Frame*);
323     static InspectorInstrumentationCookie willLayoutImpl(InstrumentingAgents*, Frame*);
324     static void didLayoutImpl(const InspectorInstrumentationCookie&);
325     static void didScrollImpl(InstrumentingAgents*);
326     static InspectorInstrumentationCookie willLoadXHRImpl(InstrumentingAgents*, XMLHttpRequest*, ScriptExecutionContext*);
327     static void didLoadXHRImpl(const InspectorInstrumentationCookie&);
328     static InspectorInstrumentationCookie willPaintImpl(InstrumentingAgents*, GraphicsContext*, const LayoutRect&, Frame*);
329     static void didPaintImpl(const InspectorInstrumentationCookie&);
330     static void willCompositeImpl(InstrumentingAgents*);
331     static void didCompositeImpl(InstrumentingAgents*);
332     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*, Frame*);
333     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
334     static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*);
335     static InspectorInstrumentationCookie willMatchRuleImpl(InstrumentingAgents*, const StyleRule*);
336     static void didMatchRuleImpl(const InspectorInstrumentationCookie&, bool matched);
337     static InspectorInstrumentationCookie willProcessRuleImpl(InstrumentingAgents*, const StyleRule*);
338     static void didProcessRuleImpl(const InspectorInstrumentationCookie&);
339     static void willProcessTaskImpl(InstrumentingAgents*);
340     static void didProcessTaskImpl(InstrumentingAgents*);
341
342     static void applyUserAgentOverrideImpl(InstrumentingAgents*, String*);
343     static void applyScreenWidthOverrideImpl(InstrumentingAgents*, long*);
344     static void applyScreenHeightOverrideImpl(InstrumentingAgents*, long*);
345     static bool shouldApplyScreenWidthOverrideImpl(InstrumentingAgents*);
346     static bool shouldApplyScreenHeightOverrideImpl(InstrumentingAgents*);
347     static void willSendRequestImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
348     static void continueAfterPingLoaderImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse&);
349     static void markResourceAsCachedImpl(InstrumentingAgents*, unsigned long identifier);
350     static void didLoadResourceFromMemoryCacheImpl(InstrumentingAgents*, DocumentLoader*, CachedResource*);
351     static InspectorInstrumentationCookie willReceiveResourceDataImpl(InstrumentingAgents*, unsigned long identifier, Frame*, int length);
352     static void didReceiveResourceDataImpl(const InspectorInstrumentationCookie&);
353     static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InstrumentingAgents*, unsigned long identifier, const ResourceResponse&, Frame*);
354     static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
355     static void didReceiveResourceResponseButCanceledImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
356     static void continueAfterXFrameOptionsDeniedImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
357     static void continueWithPolicyDownloadImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
358     static void continueWithPolicyIgnoreImpl(Frame*, DocumentLoader*, unsigned long identifier, const ResourceResponse&);
359     static void didReceiveDataImpl(InstrumentingAgents*, unsigned long identifier, const char* data, int dataLength, int encodedDataLength);
360     static void didFinishLoadingImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, double finishTime);
361     static void didFailLoadingImpl(InstrumentingAgents*, unsigned long identifier, DocumentLoader*, const ResourceError&);
362     static void resourceRetrievedByXMLHttpRequestImpl(InstrumentingAgents*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
363     static void didReceiveXHRResponseImpl(InstrumentingAgents*, unsigned long identifier);
364     static void willLoadXHRSynchronouslyImpl(InstrumentingAgents*);
365     static void didLoadXHRSynchronouslyImpl(InstrumentingAgents*);
366     static void scriptImportedImpl(InstrumentingAgents*, unsigned long identifier, const String& sourceString);
367     static void didReceiveScriptResponseImpl(InstrumentingAgents*, unsigned long identifier);
368     static void domContentLoadedEventFiredImpl(InstrumentingAgents*, Frame*);
369     static void loadEventFiredImpl(InstrumentingAgents*, Frame*);
370     static void frameDetachedFromParentImpl(InstrumentingAgents*, Frame*);
371     static void didCommitLoadImpl(InstrumentingAgents*, Page*, DocumentLoader*);
372     static void loaderDetachedFromFrameImpl(InstrumentingAgents*, DocumentLoader*);
373     static void willDestroyCachedResourceImpl(CachedResource*);
374
375     static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents*, unsigned int length, unsigned int startLine, Frame*);
376     static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine);
377
378     static void addMessageToConsoleImpl(InstrumentingAgents*, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
379     static void addMessageToConsoleImpl(InstrumentingAgents*, MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber);
380     static void consoleCountImpl(InstrumentingAgents*, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
381     static void startConsoleTimingImpl(InstrumentingAgents*, Frame*, const String& title);
382     static void stopConsoleTimingImpl(InstrumentingAgents*, Frame*, const String& title, PassRefPtr<ScriptCallStack>);
383     static void consoleTimeStampImpl(InstrumentingAgents*, Frame*, PassRefPtr<ScriptArguments>);
384
385     static void didRequestAnimationFrameImpl(InstrumentingAgents*, int callbackId, Frame*);
386     static void didCancelAnimationFrameImpl(InstrumentingAgents*, int callbackId, Frame*);
387     static InspectorInstrumentationCookie willFireAnimationFrameImpl(InstrumentingAgents*, int callbackId, Frame*);
388     static void didFireAnimationFrameImpl(const InspectorInstrumentationCookie&);
389
390 #if ENABLE(JAVASCRIPT_DEBUGGER)
391     static void addStartProfilingMessageToConsoleImpl(InstrumentingAgents*, const String& title, unsigned lineNumber, const String& sourceURL);
392     static void addProfileImpl(InstrumentingAgents*, RefPtr<ScriptProfile>, PassRefPtr<ScriptCallStack>);
393     static String getCurrentUserInitiatedProfileNameImpl(InstrumentingAgents*, bool incrementProfileNumber);
394     static bool profilerEnabledImpl(InstrumentingAgents*);
395 #endif
396
397 #if ENABLE(SQL_DATABASE)
398     static void didOpenDatabaseImpl(InstrumentingAgents*, PassRefPtr<Database>, const String& domain, const String& name, const String& version);
399 #endif
400
401     static void didUseDOMStorageImpl(InstrumentingAgents*, StorageArea*, bool isLocalStorage, Frame*);
402     static void didDispatchDOMStorageEventImpl(InstrumentingAgents*, const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*);
403
404 #if ENABLE(WORKERS)
405     static bool shouldPauseDedicatedWorkerOnStartImpl(InstrumentingAgents*);
406     static void didStartWorkerContextImpl(InstrumentingAgents*, WorkerContextProxy*, const KURL&);
407     static void workerContextTerminatedImpl(InstrumentingAgents*, WorkerContextProxy*);
408 #endif
409
410 #if ENABLE(WEB_SOCKETS)
411     static void didCreateWebSocketImpl(InstrumentingAgents*, unsigned long identifier, const KURL& requestURL, const KURL& documentURL);
412     static void willSendWebSocketHandshakeRequestImpl(InstrumentingAgents*, unsigned long identifier, const WebSocketHandshakeRequest&);
413     static void didReceiveWebSocketHandshakeResponseImpl(InstrumentingAgents*, unsigned long identifier, const WebSocketHandshakeResponse&);
414     static void didCloseWebSocketImpl(InstrumentingAgents*, unsigned long identifier);
415     static void didReceiveWebSocketFrameImpl(InstrumentingAgents*, unsigned long identifier, const WebSocketFrame&);
416     static void didSendWebSocketFrameImpl(InstrumentingAgents*, unsigned long identifier, const WebSocketFrame&);
417     static void didReceiveWebSocketFrameErrorImpl(InstrumentingAgents*, unsigned long identifier, const String&);
418 #endif
419
420     static void networkStateChangedImpl(InstrumentingAgents*);
421     static void updateApplicationCacheStatusImpl(InstrumentingAgents*, Frame*);
422
423     static InstrumentingAgents* instrumentingAgentsForPage(Page*);
424     static InstrumentingAgents* instrumentingAgentsForFrame(Frame*);
425     static InstrumentingAgents* instrumentingAgentsForContext(ScriptExecutionContext*);
426     static InstrumentingAgents* instrumentingAgentsForDocument(Document*);
427 #if ENABLE(WORKERS)
428     static InstrumentingAgents* instrumentingAgentsForWorkerContext(WorkerContext*);
429     static InstrumentingAgents* instrumentingAgentsForNonDocumentContext(ScriptExecutionContext*);
430 #endif
431
432     static bool collectingHTMLParseErrors(InstrumentingAgents*);
433     static void pauseOnNativeEventIfNeeded(InstrumentingAgents*, bool isDOMEvent, const String& eventName, bool synchronous);
434     static void cancelPauseOnNativeEvent(InstrumentingAgents*);
435     static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
436
437 #if ENABLE(GEOLOCATION)
438     static GeolocationPosition* overrideGeolocationPositionImpl(InstrumentingAgents*, GeolocationPosition*);
439 #endif
440
441     static DeviceOrientationData* overrideDeviceOrientationImpl(InstrumentingAgents*, DeviceOrientationData*);
442     static int s_frontendCounter;
443 #endif
444 };
445
446 inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
447 {
448 #if ENABLE(INSPECTOR)
449     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
450         didClearWindowObjectInWorldImpl(instrumentingAgents, frame, world);
451 #endif
452 }
453
454 inline bool InspectorInstrumentation::isDebuggerPaused(Frame* frame)
455 {
456 #if ENABLE(INSPECTOR)
457     FAST_RETURN_IF_NO_FRONTENDS(false);
458     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
459         return isDebuggerPausedImpl(instrumentingAgents);
460 #endif
461     return false;
462 }
463
464 inline void InspectorInstrumentation::willInsertDOMNode(Document* document, Node* parent)
465 {
466 #if ENABLE(INSPECTOR)
467     FAST_RETURN_IF_NO_FRONTENDS(void());
468     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
469         willInsertDOMNodeImpl(instrumentingAgents, parent);
470 #endif
471 }
472
473 inline void InspectorInstrumentation::didInsertDOMNode(Document* document, Node* node)
474 {
475 #if ENABLE(INSPECTOR)
476     FAST_RETURN_IF_NO_FRONTENDS(void());
477     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
478         didInsertDOMNodeImpl(instrumentingAgents, node);
479 #endif
480 }
481
482 inline void InspectorInstrumentation::willRemoveDOMNode(Document* document, Node* node)
483 {
484 #if ENABLE(INSPECTOR)
485     FAST_RETURN_IF_NO_FRONTENDS(void());
486     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document)) {
487         willRemoveDOMNodeImpl(instrumentingAgents, node);
488         didRemoveDOMNodeImpl(instrumentingAgents, node);
489     }
490 #endif
491 }
492
493 inline void InspectorInstrumentation::willModifyDOMAttr(Document* document, Element* element, const AtomicString& oldValue, const AtomicString& newValue)
494 {
495 #if ENABLE(INSPECTOR)
496     FAST_RETURN_IF_NO_FRONTENDS(void());
497     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
498         willModifyDOMAttrImpl(instrumentingAgents, element, oldValue, newValue);
499 #endif
500 }
501
502 inline void InspectorInstrumentation::didModifyDOMAttr(Document* document, Element* element, const AtomicString& name, const AtomicString& value)
503 {
504 #if ENABLE(INSPECTOR)
505     FAST_RETURN_IF_NO_FRONTENDS(void());
506     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
507         didModifyDOMAttrImpl(instrumentingAgents, element, name, value);
508 #endif
509 }
510
511 inline void InspectorInstrumentation::didRemoveDOMAttr(Document* document, Element* element, const AtomicString& name)
512 {
513 #if ENABLE(INSPECTOR)
514     FAST_RETURN_IF_NO_FRONTENDS(void());
515     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
516         didRemoveDOMAttrImpl(instrumentingAgents, element, name);
517 #endif
518 }
519
520 inline void InspectorInstrumentation::didInvalidateStyleAttr(Document* document, Node* node)
521 {
522 #if ENABLE(INSPECTOR)
523     FAST_RETURN_IF_NO_FRONTENDS(void());
524     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
525         didInvalidateStyleAttrImpl(instrumentingAgents, node);
526 #endif
527 }
528
529 inline void InspectorInstrumentation::frameWindowDiscarded(Frame* frame, DOMWindow* domWindow)
530 {
531 #if ENABLE(INSPECTOR)
532     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
533         frameWindowDiscardedImpl(instrumentingAgents, domWindow);
534 #endif
535 }
536
537 inline void InspectorInstrumentation::mediaQueryResultChanged(Document* document)
538 {
539 #if ENABLE(INSPECTOR)
540     FAST_RETURN_IF_NO_FRONTENDS(void());
541     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
542         mediaQueryResultChangedImpl(instrumentingAgents);
543 #endif
544 }
545
546 inline void InspectorInstrumentation::didPushShadowRoot(Element* host, ShadowRoot* root)
547 {
548 #if ENABLE(INSPECTOR)
549     FAST_RETURN_IF_NO_FRONTENDS(void());
550     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host->ownerDocument()))
551         didPushShadowRootImpl(instrumentingAgents, host, root);
552 #endif
553 }
554
555 inline void InspectorInstrumentation::willPopShadowRoot(Element* host, ShadowRoot* root)
556 {
557 #if ENABLE(INSPECTOR)
558     FAST_RETURN_IF_NO_FRONTENDS(void());
559     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(host->ownerDocument()))
560         willPopShadowRootImpl(instrumentingAgents, host, root);
561 #endif
562 }
563
564 inline void InspectorInstrumentation::didCreateNamedFlow(Document* document, const AtomicString& name)
565 {
566 #if ENABLE(INSPECTOR)
567     FAST_RETURN_IF_NO_FRONTENDS(void());
568     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
569         didCreateNamedFlowImpl(instrumentingAgents, document, name);
570 #endif
571 }
572
573 inline void InspectorInstrumentation::didRemoveNamedFlow(Document* document, const AtomicString& name)
574 {
575 #if ENABLE(INSPECTOR)
576     FAST_RETURN_IF_NO_FRONTENDS(void());
577     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
578         didRemoveNamedFlowImpl(instrumentingAgents, document, name);
579 #endif
580 }
581
582 inline void InspectorInstrumentation::mouseDidMoveOverElement(Page* page, const HitTestResult& result, unsigned modifierFlags)
583 {
584 #if ENABLE(INSPECTOR)
585     FAST_RETURN_IF_NO_FRONTENDS(void());
586     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
587         mouseDidMoveOverElementImpl(instrumentingAgents, result, modifierFlags);
588 #endif
589 }
590
591 inline bool InspectorInstrumentation::handleMousePress(Page* page)
592 {
593 #if ENABLE(INSPECTOR)
594     FAST_RETURN_IF_NO_FRONTENDS(false);
595     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
596         return handleMousePressImpl(instrumentingAgents);
597 #endif
598     return false;
599 }
600
601 inline bool InspectorInstrumentation::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoState)
602 {
603 #if ENABLE(INSPECTOR)
604     FAST_RETURN_IF_NO_FRONTENDS(false);
605     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(element->document()))
606         return forcePseudoStateImpl(instrumentingAgents, element, pseudoState);
607 #endif
608     return false;
609 }
610
611 inline void InspectorInstrumentation::characterDataModified(Document* document, CharacterData* characterData)
612 {
613 #if ENABLE(INSPECTOR)
614     FAST_RETURN_IF_NO_FRONTENDS(void());
615     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
616         characterDataModifiedImpl(instrumentingAgents, characterData);
617 #endif
618 }
619
620 inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionContext* context, const String& url)
621 {
622 #if ENABLE(INSPECTOR)
623     FAST_RETURN_IF_NO_FRONTENDS(void());
624     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
625         willSendXMLHttpRequestImpl(instrumentingAgents, url);
626 #endif
627 }
628
629 inline void InspectorInstrumentation::didScheduleResourceRequest(Document* document, const String& url)
630 {
631 #if ENABLE(INSPECTOR)
632     FAST_RETURN_IF_NO_FRONTENDS(void());
633     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
634         didScheduleResourceRequestImpl(instrumentingAgents, url, document->frame());
635 #endif
636 }
637
638 inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext* context, int timerId, int timeout, bool singleShot)
639 {
640 #if ENABLE(INSPECTOR)
641     FAST_RETURN_IF_NO_FRONTENDS(void());
642     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
643         didInstallTimerImpl(instrumentingAgents, timerId, timeout, singleShot, context);
644 #endif
645 }
646
647 inline void InspectorInstrumentation::didRemoveTimer(ScriptExecutionContext* context, int timerId)
648 {
649 #if ENABLE(INSPECTOR)
650     FAST_RETURN_IF_NO_FRONTENDS(void());
651     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
652         didRemoveTimerImpl(instrumentingAgents, timerId, context);
653 #endif
654 }
655
656 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine)
657 {
658 #if ENABLE(INSPECTOR)
659     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
660     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
661         return willCallFunctionImpl(instrumentingAgents, scriptName, scriptLine, context);
662 #endif
663     return InspectorInstrumentationCookie();
664 }
665
666
667 inline void InspectorInstrumentation::didCallFunction(const InspectorInstrumentationCookie& cookie)
668 {
669 #if ENABLE(INSPECTOR)
670     FAST_RETURN_IF_NO_FRONTENDS(void());
671     if (cookie.first)
672         didCallFunctionImpl(cookie);
673 #endif
674 }
675
676 inline InspectorInstrumentationCookie InspectorInstrumentation::willChangeXHRReadyState(ScriptExecutionContext* context, XMLHttpRequest* request)
677 {
678 #if ENABLE(INSPECTOR)
679     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
680     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
681         return willChangeXHRReadyStateImpl(instrumentingAgents, request, context);
682 #endif
683     return InspectorInstrumentationCookie();
684 }
685
686 inline void InspectorInstrumentation::didChangeXHRReadyState(const InspectorInstrumentationCookie& cookie)
687 {
688 #if ENABLE(INSPECTOR)
689     FAST_RETURN_IF_NO_FRONTENDS(void());
690     if (cookie.first)
691         didChangeXHRReadyStateImpl(cookie);
692 #endif
693 }
694
695 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEvent(Document* document, const Event& event, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors)
696 {
697 #if ENABLE(INSPECTOR)
698     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
699     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
700         return willDispatchEventImpl(instrumentingAgents, event, window, node, ancestors, document);
701 #endif
702     return InspectorInstrumentationCookie();
703 }
704
705 inline void InspectorInstrumentation::didDispatchEvent(const InspectorInstrumentationCookie& cookie)
706 {
707 #if ENABLE(INSPECTOR)
708     FAST_RETURN_IF_NO_FRONTENDS(void());
709     if (cookie.first)
710         didDispatchEventImpl(cookie);
711 #endif
712 }
713
714 inline InspectorInstrumentationCookie InspectorInstrumentation::willHandleEvent(ScriptExecutionContext* context, Event* event)
715 {
716 #if ENABLE(INSPECTOR)
717     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
718     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
719         return willHandleEventImpl(instrumentingAgents, event);
720 #endif
721     return InspectorInstrumentationCookie();
722 }
723
724 inline void InspectorInstrumentation::didHandleEvent(const InspectorInstrumentationCookie& cookie)
725 {
726 #if ENABLE(INSPECTOR)
727     FAST_RETURN_IF_NO_FRONTENDS(void());
728     if (cookie.first)
729         didHandleEventImpl(cookie);
730 #endif
731 }
732
733 inline InspectorInstrumentationCookie InspectorInstrumentation::willDispatchEventOnWindow(Frame* frame, const Event& event, DOMWindow* window)
734 {
735 #if ENABLE(INSPECTOR)
736     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
737     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
738         return willDispatchEventOnWindowImpl(instrumentingAgents, event, window);
739 #endif
740     return InspectorInstrumentationCookie();
741 }
742
743 inline void InspectorInstrumentation::didDispatchEventOnWindow(const InspectorInstrumentationCookie& cookie)
744 {
745 #if ENABLE(INSPECTOR)
746     FAST_RETURN_IF_NO_FRONTENDS(void());
747     if (cookie.first)
748         didDispatchEventOnWindowImpl(cookie);
749 #endif
750 }
751
752 inline InspectorInstrumentationCookie InspectorInstrumentation::willEvaluateScript(Frame* frame, const String& url, int lineNumber)
753 {
754 #if ENABLE(INSPECTOR)
755     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
756     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
757         return willEvaluateScriptImpl(instrumentingAgents, url, lineNumber, frame);
758 #endif
759     return InspectorInstrumentationCookie();
760 }
761
762 inline void InspectorInstrumentation::didEvaluateScript(const InspectorInstrumentationCookie& cookie)
763 {
764 #if ENABLE(INSPECTOR)
765     FAST_RETURN_IF_NO_FRONTENDS(void());
766     if (cookie.first)
767         didEvaluateScriptImpl(cookie);
768 #endif
769 }
770
771 inline void InspectorInstrumentation::didCreateIsolatedContext(Frame* frame, ScriptState* scriptState, SecurityOrigin* origin)
772 {
773 #if ENABLE(INSPECTOR)
774     FAST_RETURN_IF_NO_FRONTENDS(void());
775     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
776         return didCreateIsolatedContextImpl(instrumentingAgents, frame, scriptState, origin);
777 #endif
778 }
779
780 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireTimer(ScriptExecutionContext* context, int timerId)
781 {
782 #if ENABLE(INSPECTOR)
783     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
784     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
785         return willFireTimerImpl(instrumentingAgents, timerId, context);
786 #endif
787     return InspectorInstrumentationCookie();
788 }
789
790 inline void InspectorInstrumentation::didFireTimer(const InspectorInstrumentationCookie& cookie)
791 {
792 #if ENABLE(INSPECTOR)
793     FAST_RETURN_IF_NO_FRONTENDS(void());
794     if (cookie.first)
795         didFireTimerImpl(cookie);
796 #endif
797 }
798
799 inline void InspectorInstrumentation::didBeginFrame(Page* page)
800 {
801 #if ENABLE(INSPECTOR)
802     FAST_RETURN_IF_NO_FRONTENDS(void());
803     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
804         didBeginFrameImpl(instrumentingAgents);
805 #endif
806 }
807
808 inline void InspectorInstrumentation::didCancelFrame(Page* page)
809 {
810 #if ENABLE(INSPECTOR)
811     FAST_RETURN_IF_NO_FRONTENDS(void());
812     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
813         didCancelFrameImpl(instrumentingAgents);
814 #endif
815 }
816
817 inline void InspectorInstrumentation::didInvalidateLayout(Frame* frame)
818 {
819 #if ENABLE(INSPECTOR)
820     FAST_RETURN_IF_NO_FRONTENDS(void());
821     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
822         didInvalidateLayoutImpl(instrumentingAgents, frame);
823 #endif
824 }
825
826 inline InspectorInstrumentationCookie InspectorInstrumentation::willLayout(Frame* frame)
827 {
828 #if ENABLE(INSPECTOR)
829     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
830     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
831         return willLayoutImpl(instrumentingAgents, frame);
832 #endif
833     return InspectorInstrumentationCookie();
834 }
835
836 inline void InspectorInstrumentation::didLayout(const InspectorInstrumentationCookie& cookie)
837 {
838 #if ENABLE(INSPECTOR)
839     FAST_RETURN_IF_NO_FRONTENDS(void());
840     if (cookie.first)
841         didLayoutImpl(cookie);
842 #endif
843 }
844
845 inline void InspectorInstrumentation::didScroll(Page* page)
846 {
847 #if ENABLE(INSPECTOR)
848     FAST_RETURN_IF_NO_FRONTENDS(void());
849     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
850         didScrollImpl(instrumentingAgents);
851 #endif
852 }
853
854 inline InspectorInstrumentationCookie InspectorInstrumentation::willLoadXHR(ScriptExecutionContext* context, XMLHttpRequest* request)
855 {
856 #if ENABLE(INSPECTOR)
857     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
858     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
859         return willLoadXHRImpl(instrumentingAgents, request, context);
860 #endif
861     return InspectorInstrumentationCookie();
862 }
863
864 inline void InspectorInstrumentation::didLoadXHR(const InspectorInstrumentationCookie& cookie)
865 {
866 #if ENABLE(INSPECTOR)
867     FAST_RETURN_IF_NO_FRONTENDS(void());
868     if (cookie.first)
869         didLoadXHRImpl(cookie);
870 #endif
871 }
872
873 inline InspectorInstrumentationCookie InspectorInstrumentation::willPaint(Frame* frame, GraphicsContext* context, const LayoutRect& rect)
874 {
875 #if ENABLE(INSPECTOR)
876     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
877     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
878         return willPaintImpl(instrumentingAgents, context, rect, frame);
879 #endif
880     return InspectorInstrumentationCookie();
881 }
882
883 inline void InspectorInstrumentation::didPaint(const InspectorInstrumentationCookie& cookie)
884 {
885 #if ENABLE(INSPECTOR)
886     FAST_RETURN_IF_NO_FRONTENDS(void());
887     if (cookie.first)
888         didPaintImpl(cookie);
889 #endif
890 }
891
892 inline void InspectorInstrumentation::willComposite(Page* page)
893 {
894 #if ENABLE(INSPECTOR)
895     FAST_RETURN_IF_NO_FRONTENDS(void());
896     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
897         willCompositeImpl(instrumentingAgents);
898 #endif
899 }
900
901 inline void InspectorInstrumentation::didComposite(Page* page)
902 {
903 #if ENABLE(INSPECTOR)
904     FAST_RETURN_IF_NO_FRONTENDS(void());
905     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
906         didCompositeImpl(instrumentingAgents);
907 #endif
908 }
909
910 inline InspectorInstrumentationCookie InspectorInstrumentation::willRecalculateStyle(Document* document)
911 {
912 #if ENABLE(INSPECTOR)
913     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
914     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
915         return willRecalculateStyleImpl(instrumentingAgents, document->frame());
916 #endif
917     return InspectorInstrumentationCookie();
918 }
919
920 inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrumentationCookie& cookie)
921 {
922 #if ENABLE(INSPECTOR)
923     FAST_RETURN_IF_NO_FRONTENDS(void());
924     if (cookie.first)
925         didRecalculateStyleImpl(cookie);
926 #endif
927 }
928
929 inline void InspectorInstrumentation::didScheduleStyleRecalculation(Document* document)
930 {
931 #if ENABLE(INSPECTOR)
932     FAST_RETURN_IF_NO_FRONTENDS(void());
933     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
934         didScheduleStyleRecalculationImpl(instrumentingAgents, document);
935 #endif
936 }
937
938 inline InspectorInstrumentationCookie InspectorInstrumentation::willMatchRule(Document* document, const StyleRule* rule)
939 {
940 #if ENABLE(INSPECTOR)
941     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
942     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
943         return willMatchRuleImpl(instrumentingAgents, rule);
944 #endif
945     return InspectorInstrumentationCookie();
946 }
947
948 inline void InspectorInstrumentation::didMatchRule(const InspectorInstrumentationCookie& cookie, bool matched)
949 {
950 #if ENABLE(INSPECTOR)
951     FAST_RETURN_IF_NO_FRONTENDS(void());
952     if (cookie.first)
953         didMatchRuleImpl(cookie, matched);
954 #endif
955 }
956
957 inline InspectorInstrumentationCookie InspectorInstrumentation::willProcessRule(Document* document, const StyleRule* rule)
958 {
959 #if ENABLE(INSPECTOR)
960     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
961     if (!rule)
962         return InspectorInstrumentationCookie();
963     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
964         return willProcessRuleImpl(instrumentingAgents, rule);
965 #endif
966     return InspectorInstrumentationCookie();
967 }
968
969 inline void InspectorInstrumentation::didProcessRule(const InspectorInstrumentationCookie& cookie)
970 {
971 #if ENABLE(INSPECTOR)
972     FAST_RETURN_IF_NO_FRONTENDS(void());
973     if (cookie.first)
974         didProcessRuleImpl(cookie);
975 #endif
976 }
977
978 inline void InspectorInstrumentation::willProcessTask(Page* page)
979 {
980 #if ENABLE(INSPECTOR)
981     FAST_RETURN_IF_NO_FRONTENDS(void());
982     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
983         willProcessTaskImpl(instrumentingAgents);
984 #endif
985 }
986
987 inline void InspectorInstrumentation::didProcessTask(Page* page)
988 {
989 #if ENABLE(INSPECTOR)
990     FAST_RETURN_IF_NO_FRONTENDS(void());
991     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
992         didProcessTaskImpl(instrumentingAgents);
993 #endif
994 }
995
996 inline void InspectorInstrumentation::applyUserAgentOverride(Frame* frame, String* userAgent)
997 {
998 #if ENABLE(INSPECTOR)
999     FAST_RETURN_IF_NO_FRONTENDS(void());
1000     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1001         applyUserAgentOverrideImpl(instrumentingAgents, userAgent);
1002 #endif
1003 }
1004
1005 inline void InspectorInstrumentation::applyScreenWidthOverride(Frame* frame, long* width)
1006 {
1007 #if ENABLE(INSPECTOR)
1008     FAST_RETURN_IF_NO_FRONTENDS(void());
1009     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1010         applyScreenWidthOverrideImpl(instrumentingAgents, width);
1011 #endif
1012 }
1013
1014 inline void InspectorInstrumentation::applyScreenHeightOverride(Frame* frame, long* height)
1015 {
1016 #if ENABLE(INSPECTOR)
1017     FAST_RETURN_IF_NO_FRONTENDS(void());
1018     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1019         applyScreenHeightOverrideImpl(instrumentingAgents, height);
1020 #endif
1021 }
1022
1023 inline bool InspectorInstrumentation::shouldApplyScreenWidthOverride(Frame* frame)
1024 {
1025 #if ENABLE(INSPECTOR)
1026     FAST_RETURN_IF_NO_FRONTENDS(false);
1027     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1028         return shouldApplyScreenWidthOverrideImpl(instrumentingAgents);
1029 #endif
1030     return false;
1031 }
1032
1033 inline bool InspectorInstrumentation::shouldApplyScreenHeightOverride(Frame* frame)
1034 {
1035 #if ENABLE(INSPECTOR)
1036     FAST_RETURN_IF_NO_FRONTENDS(false);
1037     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1038         return shouldApplyScreenHeightOverrideImpl(instrumentingAgents);
1039 #endif
1040     return false;
1041 }
1042
1043 inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse)
1044 {
1045 #if ENABLE(INSPECTOR)
1046     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1047         willSendRequestImpl(instrumentingAgents, identifier, loader, request, redirectResponse);
1048 #endif
1049 }
1050
1051 inline void InspectorInstrumentation::continueAfterPingLoader(Frame* frame, unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& response)
1052 {
1053 #if ENABLE(INSPECTOR)
1054     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1055         InspectorInstrumentation::continueAfterPingLoaderImpl(instrumentingAgents, identifier, loader, request, response);
1056 #endif
1057 }
1058
1059 inline void InspectorInstrumentation::markResourceAsCached(Page* page, unsigned long identifier)
1060 {
1061 #if ENABLE(INSPECTOR)
1062     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1063         markResourceAsCachedImpl(instrumentingAgents, identifier);
1064 #endif
1065 }
1066
1067 inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page* page, DocumentLoader* loader, CachedResource* resource)
1068 {
1069 #if ENABLE(INSPECTOR)
1070     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1071         didLoadResourceFromMemoryCacheImpl(instrumentingAgents, loader, resource);
1072 #endif
1073 }
1074
1075 inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier, int length)
1076 {
1077 #if ENABLE(INSPECTOR)
1078     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1079     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1080         return willReceiveResourceDataImpl(instrumentingAgents, identifier, frame, length);
1081 #endif
1082     return InspectorInstrumentationCookie();
1083 }
1084
1085 inline void InspectorInstrumentation::didReceiveResourceData(const InspectorInstrumentationCookie& cookie)
1086 {
1087 #if ENABLE(INSPECTOR)
1088     FAST_RETURN_IF_NO_FRONTENDS(void());
1089     if (cookie.first)
1090         didReceiveResourceDataImpl(cookie);
1091 #endif
1092 }
1093
1094 inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResponse(Frame* frame, unsigned long identifier, const ResourceResponse& response)
1095 {
1096 #if ENABLE(INSPECTOR)
1097     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1098         return willReceiveResourceResponseImpl(instrumentingAgents, identifier, response, frame);
1099 #endif
1100     return InspectorInstrumentationCookie();
1101 }
1102
1103 inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
1104 {
1105 #if ENABLE(INSPECTOR)
1106     // Call this unconditionally so that we're able to log to console with no front-end attached.
1107     didReceiveResourceResponseImpl(cookie, identifier, loader, response, resourceLoader);
1108 #endif
1109 }
1110
1111 inline void InspectorInstrumentation::continueAfterXFrameOptionsDenied(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
1112 {
1113 #if ENABLE(INSPECTOR)
1114     FAST_RETURN_IF_NO_FRONTENDS(void());
1115     InspectorInstrumentation::continueAfterXFrameOptionsDeniedImpl(frame, loader, identifier, r);
1116 #endif
1117 }
1118
1119 inline void InspectorInstrumentation::continueWithPolicyDownload(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
1120 {
1121 #if ENABLE(INSPECTOR)
1122     FAST_RETURN_IF_NO_FRONTENDS(void());
1123     InspectorInstrumentation::continueWithPolicyDownloadImpl(frame, loader, identifier, r);
1124 #endif
1125 }
1126
1127 inline void InspectorInstrumentation::continueWithPolicyIgnore(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
1128 {
1129 #if ENABLE(INSPECTOR)
1130     FAST_RETURN_IF_NO_FRONTENDS(void());
1131     InspectorInstrumentation::continueWithPolicyIgnoreImpl(frame, loader, identifier, r);
1132 #endif
1133 }
1134
1135 inline void InspectorInstrumentation::didReceiveData(Frame* frame, unsigned long identifier, const char* data, int dataLength, int encodedDataLength)
1136 {
1137 #if ENABLE(INSPECTOR)
1138     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1139         didReceiveDataImpl(instrumentingAgents, identifier, data, dataLength, encodedDataLength);
1140 #endif
1141 }
1142
1143 inline void InspectorInstrumentation::didFinishLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, double finishTime)
1144 {
1145 #if ENABLE(INSPECTOR)
1146     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1147         didFinishLoadingImpl(instrumentingAgents, identifier, loader, finishTime);
1148 #endif
1149 }
1150
1151 inline void InspectorInstrumentation::didFailLoading(Frame* frame, DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
1152 {
1153 #if ENABLE(INSPECTOR)
1154     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1155         didFailLoadingImpl(instrumentingAgents, identifier, loader, error);
1156 #endif
1157 }
1158
1159 inline void InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
1160 {
1161 #if ENABLE(INSPECTOR)
1162     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1163         resourceRetrievedByXMLHttpRequestImpl(instrumentingAgents, identifier, sourceString, url, sendURL, sendLineNumber);
1164 #endif
1165 }
1166
1167 inline void InspectorInstrumentation::didReceiveXHRResponse(ScriptExecutionContext* context, unsigned long identifier)
1168 {
1169 #if ENABLE(INSPECTOR)
1170     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1171         didReceiveXHRResponseImpl(instrumentingAgents, identifier);
1172 #endif
1173 }
1174
1175 inline void InspectorInstrumentation::willLoadXHRSynchronously(ScriptExecutionContext* context)
1176 {
1177 #if ENABLE(INSPECTOR)
1178     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1179         willLoadXHRSynchronouslyImpl(instrumentingAgents);
1180 #endif
1181 }
1182
1183 inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionContext* context)
1184 {
1185 #if ENABLE(INSPECTOR)
1186     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1187         didLoadXHRSynchronouslyImpl(instrumentingAgents);
1188 #endif
1189 }
1190
1191 inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString)
1192 {
1193 #if ENABLE(INSPECTOR)
1194     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1195         scriptImportedImpl(instrumentingAgents, identifier, sourceString);
1196 #endif
1197 }
1198
1199 inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier)
1200 {
1201 #if ENABLE(INSPECTOR)
1202     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1203         didReceiveScriptResponseImpl(instrumentingAgents, identifier);
1204 #endif
1205 }
1206
1207 inline void InspectorInstrumentation::domContentLoadedEventFired(Frame* frame)
1208 {
1209 #if ENABLE(INSPECTOR)
1210     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1211         domContentLoadedEventFiredImpl(instrumentingAgents, frame);
1212 #endif
1213 }
1214
1215 inline void InspectorInstrumentation::loadEventFired(Frame* frame)
1216 {
1217 #if ENABLE(INSPECTOR)
1218     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1219         loadEventFiredImpl(instrumentingAgents, frame);
1220 #endif
1221 }
1222
1223 inline void InspectorInstrumentation::frameDetachedFromParent(Frame* frame)
1224 {
1225 #if ENABLE(INSPECTOR)
1226     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1227         frameDetachedFromParentImpl(instrumentingAgents, frame);
1228 #endif
1229 }
1230
1231 inline void InspectorInstrumentation::didCommitLoad(Frame* frame, DocumentLoader* loader)
1232 {
1233 #if ENABLE(INSPECTOR)
1234     if (!frame)
1235         return;
1236     Page* page = frame->page();
1237     if (!page)
1238         return;
1239     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1240         didCommitLoadImpl(instrumentingAgents, page, loader);
1241 #endif
1242 }
1243
1244 inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame* frame, DocumentLoader* loader)
1245 {
1246 #if ENABLE(INSPECTOR)
1247     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1248         loaderDetachedFromFrameImpl(instrumentingAgents, loader);
1249 #endif
1250 }
1251
1252 inline void InspectorInstrumentation::willDestroyCachedResource(CachedResource* cachedResource)
1253 {
1254 #if ENABLE(INSPECTOR)
1255     FAST_RETURN_IF_NO_FRONTENDS(void());
1256     willDestroyCachedResourceImpl(cachedResource);
1257 #endif
1258 }
1259
1260 inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine)
1261 {
1262 #if ENABLE(INSPECTOR)
1263     FAST_RETURN_IF_NO_FRONTENDS(InspectorInstrumentationCookie());
1264     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1265         return willWriteHTMLImpl(instrumentingAgents, length, startLine, document->frame());
1266 #endif
1267     return InspectorInstrumentationCookie();
1268 }
1269
1270 inline void InspectorInstrumentation::didWriteHTML(const InspectorInstrumentationCookie& cookie, unsigned int endLine)
1271 {
1272 #if ENABLE(INSPECTOR)
1273     FAST_RETURN_IF_NO_FRONTENDS(void());
1274     if (cookie.first)
1275         didWriteHTMLImpl(cookie, endLine);
1276 #endif
1277 }
1278
1279 inline void InspectorInstrumentation::didUseDOMStorage(Page* page, StorageArea* storageArea, bool isLocalStorage, Frame* frame)
1280 {
1281 #if ENABLE(INSPECTOR)
1282     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1283         didUseDOMStorageImpl(instrumentingAgents, storageArea, isLocalStorage, frame);
1284 #endif
1285 }
1286
1287 inline void InspectorInstrumentation::didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Page* page)
1288 {
1289 #if ENABLE(INSPECTOR)
1290     FAST_RETURN_IF_NO_FRONTENDS(void());
1291     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1292         didDispatchDOMStorageEventImpl(instrumentingAgents, key, oldValue, newValue, storageType, securityOrigin, page);
1293 #endif // ENABLE(INSPECTOR)
1294 }
1295
1296 #if ENABLE(WORKERS)
1297 inline bool InspectorInstrumentation::shouldPauseDedicatedWorkerOnStart(ScriptExecutionContext* context)
1298 {
1299 #if ENABLE(INSPECTOR)
1300     FAST_RETURN_IF_NO_FRONTENDS(false);
1301     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1302         return shouldPauseDedicatedWorkerOnStartImpl(instrumentingAgents);
1303 #endif
1304     return false;
1305 }
1306
1307 inline void InspectorInstrumentation::didStartWorkerContext(ScriptExecutionContext* context, WorkerContextProxy* proxy, const KURL& url)
1308 {
1309 #if ENABLE(INSPECTOR)
1310     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1311         didStartWorkerContextImpl(instrumentingAgents, proxy, url);
1312 #endif
1313 }
1314
1315 inline void InspectorInstrumentation::workerContextTerminated(ScriptExecutionContext* context, WorkerContextProxy* proxy)
1316 {
1317 #if ENABLE(INSPECTOR)
1318     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1319         workerContextTerminatedImpl(instrumentingAgents, proxy);
1320 #endif
1321 }
1322
1323 #endif
1324
1325
1326 #if ENABLE(WEB_SOCKETS)
1327 inline void InspectorInstrumentation::didCreateWebSocket(ScriptExecutionContext* context, unsigned long identifier, const KURL& requestURL, const KURL& documentURL)
1328 {
1329 #if ENABLE(INSPECTOR)
1330     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1331         didCreateWebSocketImpl(instrumentingAgents, identifier, requestURL, documentURL);
1332 #endif
1333 }
1334
1335 inline void InspectorInstrumentation::willSendWebSocketHandshakeRequest(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeRequest& request)
1336 {
1337 #if ENABLE(INSPECTOR)
1338     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1339         willSendWebSocketHandshakeRequestImpl(instrumentingAgents, identifier, request);
1340 #endif
1341 }
1342
1343 inline void InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(ScriptExecutionContext* context, unsigned long identifier, const WebSocketHandshakeResponse& response)
1344 {
1345 #if ENABLE(INSPECTOR)
1346     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1347         didReceiveWebSocketHandshakeResponseImpl(instrumentingAgents, identifier, response);
1348 #endif
1349 }
1350
1351 inline void InspectorInstrumentation::didCloseWebSocket(ScriptExecutionContext* context, unsigned long identifier)
1352 {
1353 #if ENABLE(INSPECTOR)
1354     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
1355         didCloseWebSocketImpl(instrumentingAgents, identifier);
1356 #endif
1357 }
1358 inline void InspectorInstrumentation::didReceiveWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1359 {
1360 #if ENABLE(INSPECTOR)
1361     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1362         didReceiveWebSocketFrameImpl(instrumentingAgents, identifier, frame);
1363 #endif
1364 }
1365 inline void InspectorInstrumentation::didReceiveWebSocketFrameError(Document* document, unsigned long identifier, const String& errorMessage)
1366 {
1367 #if ENABLE(INSPECTOR)
1368     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1369         didReceiveWebSocketFrameErrorImpl(instrumentingAgents, identifier, errorMessage);
1370 #endif
1371 }
1372 inline void InspectorInstrumentation::didSendWebSocketFrame(Document* document, unsigned long identifier, const WebSocketFrame& frame)
1373 {
1374 #if ENABLE(INSPECTOR)
1375     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1376         didSendWebSocketFrameImpl(instrumentingAgents, identifier, frame);
1377 #endif
1378 }
1379 #endif
1380
1381 inline void InspectorInstrumentation::networkStateChanged(Page* page)
1382 {
1383 #if ENABLE(INSPECTOR)
1384     FAST_RETURN_IF_NO_FRONTENDS(void());
1385     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1386         networkStateChangedImpl(instrumentingAgents);
1387 #endif
1388 }
1389
1390 inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
1391 {
1392 #if ENABLE(INSPECTOR)
1393     FAST_RETURN_IF_NO_FRONTENDS(void());
1394     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
1395         updateApplicationCacheStatusImpl(instrumentingAgents, frame);
1396 #endif
1397 }
1398
1399 inline void InspectorInstrumentation::didRequestAnimationFrame(Document* document, int callbackId)
1400 {
1401 #if ENABLE(INSPECTOR)
1402     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1403         didRequestAnimationFrameImpl(instrumentingAgents, callbackId, document->frame());
1404 #endif
1405 }
1406
1407 inline void InspectorInstrumentation::didCancelAnimationFrame(Document* document, int callbackId)
1408 {
1409 #if ENABLE(INSPECTOR)
1410     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1411         didCancelAnimationFrameImpl(instrumentingAgents, callbackId, document->frame());
1412 #endif
1413 }
1414
1415 inline InspectorInstrumentationCookie InspectorInstrumentation::willFireAnimationFrame(Document* document, int callbackId)
1416 {
1417 #if ENABLE(INSPECTOR)
1418     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(document))
1419         return willFireAnimationFrameImpl(instrumentingAgents, callbackId, document->frame());
1420 #endif
1421     return InspectorInstrumentationCookie();
1422 }
1423
1424 inline void InspectorInstrumentation::didFireAnimationFrame(const InspectorInstrumentationCookie& cookie)
1425 {
1426 #if ENABLE(INSPECTOR)
1427     FAST_RETURN_IF_NO_FRONTENDS(void());
1428     if (cookie.first)
1429         didFireAnimationFrameImpl(cookie);
1430 #endif
1431 }
1432
1433 #if ENABLE(GEOLOCATION)
1434 inline GeolocationPosition* InspectorInstrumentation::overrideGeolocationPosition(Page* page, GeolocationPosition* position)
1435 {
1436 #if ENABLE(INSPECTOR)
1437     FAST_RETURN_IF_NO_FRONTENDS(position);
1438     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1439         return overrideGeolocationPositionImpl(instrumentingAgents, position);
1440 #endif
1441     return position;
1442 }
1443 #endif
1444
1445 inline DeviceOrientationData* InspectorInstrumentation::overrideDeviceOrientation(Page* page, DeviceOrientationData* deviceOrientation)
1446 {
1447 #if ENABLE(INSPECTOR)
1448     FAST_RETURN_IF_NO_FRONTENDS(deviceOrientation);
1449     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1450         return overrideDeviceOrientationImpl(instrumentingAgents, deviceOrientation);
1451 #endif
1452     return deviceOrientation;
1453 }
1454
1455 #if ENABLE(INSPECTOR)
1456 inline bool InspectorInstrumentation::collectingHTMLParseErrors(Page* page)
1457 {
1458     FAST_RETURN_IF_NO_FRONTENDS(false);
1459     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
1460         return collectingHTMLParseErrors(instrumentingAgents);
1461     return false;
1462 }
1463
1464 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForContext(ScriptExecutionContext* context)
1465 {
1466     if (!context)
1467         return 0;
1468     if (context->isDocument())
1469         return instrumentingAgentsForPage(static_cast<Document*>(context)->page());
1470 #if ENABLE(WORKERS)
1471     return instrumentingAgentsForNonDocumentContext(context);
1472 #else
1473     return 0;
1474 #endif
1475 }
1476
1477 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(Frame* frame)
1478 {
1479     if (frame)
1480         return instrumentingAgentsForPage(frame->page());
1481     return 0;
1482 }
1483
1484 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForDocument(Document* document)
1485 {
1486     if (document)
1487         return instrumentingAgentsForPage(document->page());
1488     return 0;
1489 }
1490 #endif
1491
1492 } // namespace WebCore
1493
1494 #endif // !defined(InspectorInstrumentation_h)