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