Changeset 243303 in webkit
- Timestamp:
- Mar 21, 2019 11:22:08 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243298 r243303 1 2019-03-21 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Page: lazily create the agent 4 https://bugs.webkit.org/show_bug.cgi?id=195592 5 <rdar://problem/48791916> 6 7 Reviewed by Timothy Hatcher. 8 9 No change in functionality. 10 11 Have more agents save the inspected `Page` so they don't need to access it via the 12 `InspectorPageAgent`. Make some of `InspectorPageAgent`'s functions `static` so other 13 agents can use them without needing to have access to an enabled `InspectorPageAgent`. 14 15 * inspector/InspectorController.cpp: 16 (WebCore::InspectorController::InspectorController): 17 (WebCore::InspectorController::createLazyAgents): 18 19 * inspector/agents/InspectorPageAgent.h: 20 (WebCore::InspectorPageAgent::page): Deleted. 21 * inspector/agents/InspectorPageAgent.cpp: 22 (WebCore::InspectorPageAgent::InspectorPageAgent): 23 (WebCore::InspectorPageAgent::enable): 24 (WebCore::InspectorPageAgent::disable): 25 (WebCore::InspectorPageAgent::reload): 26 (WebCore::InspectorPageAgent::navigate): 27 (WebCore::InspectorPageAgent::overrideSetting): 28 (WebCore::InspectorPageAgent::getCookies): 29 (WebCore::InspectorPageAgent::deleteCookie): 30 (WebCore::InspectorPageAgent::getResourceTree): 31 (WebCore::InspectorPageAgent::searchInResources): 32 (WebCore::InspectorPageAgent::didPaint): 33 (WebCore::InspectorPageAgent::didLayout): 34 (WebCore::InspectorPageAgent::didScroll): 35 (WebCore::InspectorPageAgent::didRecalculateStyle): 36 (WebCore::InspectorPageAgent::setEmulatedMedia): 37 (WebCore::InspectorPageAgent::setForcedAppearance): 38 (WebCore::InspectorPageAgent::getCompositingBordersVisible): 39 (WebCore::InspectorPageAgent::setCompositingBordersVisible): 40 (WebCore::InspectorPageAgent::snapshotNode): 41 (WebCore::InspectorPageAgent::snapshotRect): 42 (WebCore::InspectorPageAgent::archive): 43 (WebCore::InspectorPageAgent::mainFrame): Deleted. 44 (WebCore::InspectorPageAgent::hasIdForFrame const): Deleted. 45 46 * inspector/agents/InspectorApplicationCacheAgent.h: 47 * inspector/agents/InspectorApplicationCacheAgent.cpp: 48 (WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent): 49 (WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus): 50 (WebCore::InspectorApplicationCacheAgent::getFramesWithManifests): 51 (WebCore::InspectorApplicationCacheAgent::assertFrameWithDocumentLoader): 52 53 * inspector/agents/InspectorCanvasAgent.h: 54 * inspector/agents/InspectorCanvasAgent.cpp: 55 (WebCore::InspectorCanvasAgent::InspectorCanvasAgent): 56 (WebCore::InspectorCanvasAgent::enable): 57 58 * inspector/agents/InspectorDOMStorageAgent.h: 59 * inspector/agents/InspectorDOMStorageAgent.cpp: 60 (WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent): 61 (WebCore::InspectorDOMStorageAgent::findStorageArea): 62 63 * inspector/agents/InspectorIndexedDBAgent.h: 64 * inspector/agents/InspectorIndexedDBAgent.cpp: 65 (WebCore::InspectorIndexedDBAgent::InspectorIndexedDBAgent): 66 (WebCore::InspectorIndexedDBAgent::requestDatabaseNames): 67 (WebCore::InspectorIndexedDBAgent::requestDatabase): 68 (WebCore::InspectorIndexedDBAgent::requestData): 69 (WebCore::InspectorIndexedDBAgent::clearObjectStore): 70 71 * inspector/agents/page/PageDebuggerAgent.h: 72 * inspector/agents/page/PageDebuggerAgent.cpp: 73 (WebCore::PageDebuggerAgent::PageDebuggerAgent): 74 (WebCore::PageDebuggerAgent::sourceMapURLForScript): 75 (WebCore::PageDebuggerAgent::breakpointActionLog): 76 (WebCore::PageDebuggerAgent::injectedScriptForEval): 77 78 * inspector/agents/page/PageNetworkAgent.h: 79 * inspector/agents/page/PageNetworkAgent.cpp: 80 (WebCore::PageNetworkAgent::PageNetworkAgent): 81 (WebCore::PageNetworkAgent::loaderIdentifier): 82 (WebCore::PageNetworkAgent::frameIdentifier): 83 (WebCore::PageNetworkAgent::setResourceCachingDisabled): 84 (WebCore::PageNetworkAgent::scriptExecutionContext): 85 86 * inspector/InspectorInstrumentation.cpp: 87 (WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl): 88 1 89 2019-03-21 Brent Fulgham <bfulgham@apple.com> 2 90 -
trunk/Source/WebCore/inspector/InspectorController.cpp
r243273 r243303 111 111 m_agents.append(WTFMove(inspectorAgentPtr)); 112 112 113 auto pageAgentPtr = std::make_unique<InspectorPageAgent>(pageContext, inspectorClient, m_overlay.get());114 m_pageAgent = pageAgentPtr.get();115 m_agents.append(WTFMove(pageAgentPtr));116 117 113 auto consoleAgent = std::make_unique<PageConsoleAgent>(pageContext); 118 114 m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get()); … … 161 157 auto pageContext = pageAgentContext(); 162 158 159 auto pageAgentPtr = std::make_unique<InspectorPageAgent>(pageContext, m_inspectorClient, m_overlay.get()); 160 m_pageAgent = pageAgentPtr.get(); 161 m_agents.append(WTFMove(pageAgentPtr)); 162 163 163 m_agents.append(std::make_unique<PageRuntimeAgent>(pageContext)); 164 164 165 auto debuggerAgent = std::make_unique<PageDebuggerAgent>(pageContext , m_pageAgent);165 auto debuggerAgent = std::make_unique<PageDebuggerAgent>(pageContext); 166 166 auto debuggerAgentPtr = debuggerAgent.get(); 167 167 m_agents.append(WTFMove(debuggerAgent)); 168 168 169 m_agents.append(std::make_unique<PageNetworkAgent>(pageContext , m_pageAgent));169 m_agents.append(std::make_unique<PageNetworkAgent>(pageContext)); 170 170 m_agents.append(std::make_unique<InspectorCSSAgent>(pageContext)); 171 171 m_agents.append(std::make_unique<InspectorDOMAgent>(pageContext, m_overlay.get())); 172 172 m_agents.append(std::make_unique<InspectorDOMDebuggerAgent>(pageContext, debuggerAgentPtr)); 173 m_agents.append(std::make_unique<InspectorApplicationCacheAgent>(pageContext , m_pageAgent));173 m_agents.append(std::make_unique<InspectorApplicationCacheAgent>(pageContext)); 174 174 m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext)); 175 175 m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext)); … … 177 177 m_agents.append(std::make_unique<InspectorDatabaseAgent>(pageContext)); 178 178 #if ENABLE(INDEXED_DATABASE) 179 m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext , m_pageAgent));179 m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext)); 180 180 #endif 181 181 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r243269 r243303 110 110 void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world) 111 111 { 112 InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent();113 112 if (PageDebuggerAgent* debuggerAgent = instrumentingAgents.pageDebuggerAgent()) { 114 if ( pageAgent && &world == &mainThreadNormalWorld() && &frame == &pageAgent->mainFrame())113 if (&world == &mainThreadNormalWorld() && frame.isMainFrame()) 115 114 debuggerAgent->didClearMainFrameWindowObject(); 116 115 } 116 117 117 if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent()) { 118 118 if (&world == &mainThreadNormalWorld()) -
trunk/Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.cpp
r233122 r243303 41 41 using namespace Inspector; 42 42 43 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent( WebAgentContext& context, InspectorPageAgent* pageAgent)43 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(PageAgentContext& context) 44 44 : InspectorAgentBase("ApplicationCache"_s, context) 45 45 , m_frontendDispatcher(std::make_unique<Inspector::ApplicationCacheFrontendDispatcher>(context.frontendRouter)) 46 46 , m_backendDispatcher(Inspector::ApplicationCacheBackendDispatcher::create(context.backendDispatcher, this)) 47 , m_ pageAgent(pageAgent)47 , m_inspectedPage(context.inspectedPage) 48 48 { 49 49 } … … 68 68 void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame) 69 69 { 70 auto* pageAgent = m_instrumentingAgents.inspectorPageAgent(); 71 if (!pageAgent) 72 return; 73 70 74 if (!frame) 71 75 return; 76 72 77 auto* documentLoader = frame->loader().documentLoader(); 73 78 if (!documentLoader) … … 78 83 auto manifestURL = host.applicationCacheInfo().manifest.string(); 79 84 80 m_frontendDispatcher->applicationCacheStatusUpdated( m_pageAgent->frameId(frame), manifestURL, status);85 m_frontendDispatcher->applicationCacheStatusUpdated(pageAgent->frameId(frame), manifestURL, status); 81 86 } 82 87 … … 90 95 result = JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>::create(); 91 96 92 for (Frame* frame = &m_pageAgent->mainFrame(); frame; frame = frame->tree().traverseNext()) { 97 auto* pageAgent = m_instrumentingAgents.inspectorPageAgent(); 98 99 for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) { 93 100 auto* documentLoader = frame->loader().documentLoader(); 94 101 if (!documentLoader) … … 99 106 if (!manifestURL.isEmpty()) { 100 107 result->addItem(Inspector::Protocol::ApplicationCache::FrameWithManifest::create() 101 .setFrameId( m_pageAgent->frameId(frame))108 .setFrameId(pageAgent->frameId(frame)) 102 109 .setManifestURL(manifestURL) 103 110 .setStatus(static_cast<int>(host.status())) … … 109 116 DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(ErrorString& errorString, const String& frameId) 110 117 { 111 Frame* frame = m_pageAgent->assertFrame(errorString, frameId); 118 auto* pageAgent = m_instrumentingAgents.inspectorPageAgent(); 119 if (!pageAgent) { 120 errorString = "Missing Page agent"_s; 121 return nullptr; 122 } 123 124 Frame* frame = pageAgent->assertFrame(errorString, frameId); 112 125 if (!frame) 113 126 return nullptr; -
trunk/Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.h
r228218 r243303 38 38 39 39 class Frame; 40 class InspectorPageAgent;41 40 class Page; 42 41 … … 47 46 WTF_MAKE_FAST_ALLOCATED; 48 47 public: 49 InspectorApplicationCacheAgent( WebAgentContext&, InspectorPageAgent*);48 InspectorApplicationCacheAgent(PageAgentContext&); 50 49 virtual ~InspectorApplicationCacheAgent() = default; 51 50 … … 53 52 void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override; 54 53 54 // InspectorInstrumentation 55 55 void updateApplicationCacheStatus(Frame*); 56 56 void networkStateChanged(); 57 57 58 // ApplicationCacheBackendDispatcherHandler 58 59 void enable(ErrorString&) override; 59 60 void getFramesWithManifests(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>>& result) override; … … 70 71 std::unique_ptr<Inspector::ApplicationCacheFrontendDispatcher> m_frontendDispatcher; 71 72 RefPtr<Inspector::ApplicationCacheBackendDispatcher> m_backendDispatcher; 72 InspectorPageAgent* m_pageAgent { nullptr };73 Page& m_inspectedPage; 73 74 }; 74 75 -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
r243029 r243303 72 72 using namespace Inspector; 73 73 74 InspectorCanvasAgent::InspectorCanvasAgent( WebAgentContext& context)74 InspectorCanvasAgent::InspectorCanvasAgent(PageAgentContext& context) 75 75 : InspectorAgentBase("Canvas"_s, context) 76 76 , m_frontendDispatcher(std::make_unique<Inspector::CanvasFrontendDispatcher>(context.frontendRouter)) 77 77 , m_backendDispatcher(Inspector::CanvasBackendDispatcher::create(context.backendDispatcher, this)) 78 78 , m_injectedScriptManager(context.injectedScriptManager) 79 , m_inspectedPage(context.inspectedPage) 79 80 , m_canvasDestroyedTimer(*this, &InspectorCanvasAgent::canvasDestroyedTimerFired) 80 81 , m_canvasRecordingTimer(*this, &InspectorCanvasAgent::canvasRecordingTimerFired) … … 112 113 return false; 113 114 114 if (auto* inspectorPageAgent = m_instrumentingAgents.inspectorPageAgent()) { 115 // FIXME: <https://webkit.org/b/168475> Web Inspector: Correctly display iframe's WebSockets 116 auto* document = downcast<Document>(scriptExecutionContext); 117 return document->page() == &inspectorPageAgent->page(); 118 } 119 120 return false; 115 // FIXME: <https://webkit.org/b/168475> Web Inspector: Correctly display iframe's WebSockets 116 auto* document = downcast<Document>(scriptExecutionContext); 117 return document->page() == &m_inspectedPage; 121 118 }; 122 119 -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h
r242594 r243303 60 60 WTF_MAKE_FAST_ALLOCATED; 61 61 public: 62 explicit InspectorCanvasAgent( WebAgentContext&);62 explicit InspectorCanvasAgent(PageAgentContext&); 63 63 virtual ~InspectorCanvasAgent() = default; 64 64 … … 129 129 std::unique_ptr<Inspector::CanvasFrontendDispatcher> m_frontendDispatcher; 130 130 RefPtr<Inspector::CanvasBackendDispatcher> m_backendDispatcher; 131 131 132 Inspector::InjectedScriptManager& m_injectedScriptManager; 133 Page& m_inspectedPage; 134 132 135 HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas; 133 136 Vector<String> m_removedCanvasIdentifiers; 137 Optional<size_t> m_recordingAutoCaptureFrameCount; 134 138 Timer m_canvasDestroyedTimer; 135 139 Timer m_canvasRecordingTimer; 136 Optional<size_t> m_recordingAutoCaptureFrameCount;137 140 }; 138 141 -
trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp
r243158 r243303 55 55 using namespace Inspector; 56 56 57 InspectorDOMStorageAgent::InspectorDOMStorageAgent( WebAgentContext& context)57 InspectorDOMStorageAgent::InspectorDOMStorageAgent(PageAgentContext& context) 58 58 : InspectorAgentBase("DOMStorage"_s, context) 59 59 , m_frontendDispatcher(std::make_unique<Inspector::DOMStorageFrontendDispatcher>(context.frontendRouter)) 60 60 , m_backendDispatcher(Inspector::DOMStorageBackendDispatcher::create(context.backendDispatcher, this)) 61 , m_inspectedPage(context.inspectedPage) 61 62 { 62 63 } … … 179 180 } 180 181 181 auto* pageAgent = m_instrumentingAgents.inspectorPageAgent(); 182 ASSERT(pageAgent); 183 if (!pageAgent) { 184 errorString = "Missing Page agent"_s; 185 return nullptr; 186 } 187 188 targetFrame = pageAgent->findFrameWithSecurityOrigin(securityOrigin); 182 targetFrame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin); 189 183 if (!targetFrame) { 190 184 errorString = "Frame not found for the given security origin"_s; … … 193 187 194 188 if (!isLocalStorage) 195 return pageAgent->page().sessionStorage()->storageArea(targetFrame->document()->securityOrigin().data());196 return pageAgent->page().storageNamespaceProvider().localStorageArea(*targetFrame->document());189 return m_inspectedPage.sessionStorage()->storageArea(targetFrame->document()->securityOrigin().data()); 190 return m_inspectedPage.storageNamespaceProvider().localStorageArea(*targetFrame->document()); 197 191 } 198 192 -
trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h
r243158 r243303 52 52 WTF_MAKE_FAST_ALLOCATED; 53 53 public: 54 InspectorDOMStorageAgent( WebAgentContext&);54 InspectorDOMStorageAgent(PageAgentContext&); 55 55 virtual ~InspectorDOMStorageAgent() = default; 56 56 … … 77 77 std::unique_ptr<Inspector::DOMStorageFrontendDispatcher> m_frontendDispatcher; 78 78 RefPtr<Inspector::DOMStorageBackendDispatcher> m_backendDispatcher; 79 80 Page& m_inspectedPage; 79 81 }; 80 82 -
trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp
r241196 r243303 520 520 } // namespace 521 521 522 InspectorIndexedDBAgent::InspectorIndexedDBAgent( WebAgentContext& context, InspectorPageAgent* pageAgent)522 InspectorIndexedDBAgent::InspectorIndexedDBAgent(PageAgentContext& context) 523 523 : InspectorAgentBase("IndexedDB"_s, context) 524 524 , m_injectedScriptManager(context.injectedScriptManager) 525 525 , m_backendDispatcher(Inspector::IndexedDBBackendDispatcher::create(context.backendDispatcher, this)) 526 , m_pageAgent(pageAgent) 527 { 528 } 529 530 InspectorIndexedDBAgent::~InspectorIndexedDBAgent() = default; 526 , m_inspectedPage(context.inspectedPage) 527 { 528 } 531 529 532 530 void InspectorIndexedDBAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) … … 591 589 void InspectorIndexedDBAgent::requestDatabaseNames(const String& securityOrigin, Ref<RequestDatabaseNamesCallback>&& callback) 592 590 { 593 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);591 auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin); 594 592 Document* document; 595 593 IDBFactory* idbFactory; … … 613 611 void InspectorIndexedDBAgent::requestDatabase(const String& securityOrigin, const String& databaseName, Ref<RequestDatabaseCallback>&& callback) 614 612 { 615 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);613 auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin); 616 614 Document* document; 617 615 IDBFactory* idbFactory; … … 625 623 void InspectorIndexedDBAgent::requestData(const String& securityOrigin, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const JSON::Object* keyRange, Ref<RequestDataCallback>&& callback) 626 624 { 627 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);625 auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin); 628 626 Document* document; 629 627 IDBFactory* idbFactory; … … 736 734 void InspectorIndexedDBAgent::clearObjectStore(const String& securityOrigin, const String& databaseName, const String& objectStoreName, Ref<ClearObjectStoreCallback>&& callback) 737 735 { 738 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);736 auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin); 739 737 Document* document; 740 738 IDBFactory* idbFactory; -
trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.h
r229493 r243303 44 44 namespace WebCore { 45 45 46 class InspectorPageAgent;46 class Page; 47 47 48 48 typedef String ErrorString; … … 52 52 WTF_MAKE_FAST_ALLOCATED; 53 53 public: 54 InspectorIndexedDBAgent( WebAgentContext&, InspectorPageAgent*);55 virtual ~InspectorIndexedDBAgent() ;54 InspectorIndexedDBAgent(PageAgentContext&); 55 virtual ~InspectorIndexedDBAgent() = default; 56 56 57 57 void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override; 58 58 void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override; 59 59 60 // Called from the front-end.60 // IndexedDBBackendDispatcherHandler 61 61 void enable(ErrorString&) override; 62 62 void disable(ErrorString&) override; … … 69 69 Inspector::InjectedScriptManager& m_injectedScriptManager; 70 70 RefPtr<Inspector::IndexedDBBackendDispatcher> m_backendDispatcher; 71 InspectorPageAgent* m_pageAgent { nullptr }; 71 72 Page& m_inspectedPage; 72 73 }; 73 74 -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
r242941 r243303 310 310 } 311 311 312 Frame* InspectorPageAgent::findFrameWithSecurityOrigin(Page& page, const String& originRawString) 313 { 314 for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) { 315 if (frame->document()->securityOrigin().toRawString() == originRawString) 316 return frame; 317 } 318 return nullptr; 319 } 320 321 DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString& errorString, Frame* frame) 322 { 323 FrameLoader& frameLoader = frame->loader(); 324 DocumentLoader* documentLoader = frameLoader.documentLoader(); 325 if (!documentLoader) 326 errorString = "No documentLoader for given frame found"_s; 327 return documentLoader; 328 } 329 312 330 InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClient* client, InspectorOverlay* overlay) 313 331 : InspectorAgentBase("Page"_s, context) 314 332 , m_frontendDispatcher(std::make_unique<Inspector::PageFrontendDispatcher>(context.frontendRouter)) 315 333 , m_backendDispatcher(Inspector::PageBackendDispatcher::create(context.backendDispatcher, this)) 316 , m_ page(context.inspectedPage)334 , m_inspectedPage(context.inspectedPage) 317 335 , m_client(client) 318 336 , m_overlay(overlay) … … 337 355 void InspectorPageAgent::enable(ErrorString&) 338 356 { 339 m_enabled = true; 357 if (m_instrumentingAgents.inspectorPageAgent() == this) 358 return; 359 340 360 m_instrumentingAgents.setInspectorPageAgent(this); 341 361 … … 345 365 346 366 #if HAVE(OS_DARK_MODE_SUPPORT) 347 defaultAppearanceDidChange(m_ page.defaultUseDarkAppearance());367 defaultAppearanceDidChange(m_inspectedPage.defaultUseDarkAppearance()); 348 368 #endif 349 369 } … … 351 371 void InspectorPageAgent::disable(ErrorString&) 352 372 { 353 m_enabled = false;354 m_instrumentingAgents.setInspectorPageAgent(nullptr);355 356 373 ErrorString unused; 357 374 setShowPaintRects(unused, false); … … 362 379 363 380 #define DISABLE_INSPECTOR_OVERRIDE_SETTING(name) \ 364 m_ page.settings().set##name##InspectorOverride(WTF::nullopt);381 m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt); 365 382 366 383 FOR_EACH_INSPECTOR_OVERRIDE_SETTING(DISABLE_INSPECTOR_OVERRIDE_SETTING) 367 384 368 385 #undef DISABLE_INSPECTOR_OVERRIDE_SETTING 386 387 m_instrumentingAgents.setInspectorPageAgent(nullptr); 369 388 } 370 389 … … 380 399 reloadOptions.add(ReloadOption::ExpiredOnly); 381 400 382 m_ page.mainFrame().loader().reload(reloadOptions);401 m_inspectedPage.mainFrame().loader().reload(reloadOptions); 383 402 } 384 403 … … 386 405 { 387 406 UserGestureIndicator indicator { ProcessingUserGesture }; 388 Frame& frame = m_ page.mainFrame();407 Frame& frame = m_inspectedPage.mainFrame(); 389 408 390 409 ResourceRequest resourceRequest { frame.document()->completeURL(url) }; … … 415 434 case Inspector::Protocol::Page::Setting::name: { \ 416 435 if (value) \ 417 m_ page.settings().set##name##InspectorOverride(*value); \436 m_inspectedPage.settings().set##name##InspectorOverride(*value); \ 418 437 else \ 419 m_ page.settings().set##name##InspectorOverride(WTF::nullopt); \438 m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt); \ 420 439 return; \ 421 440 } \ … … 494 513 bool rawCookiesImplemented = false; 495 514 496 for (Frame* frame = &m ainFrame(); frame; frame = frame->tree().traverseNext()) {515 for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) { 497 516 Document* document = frame->document(); 498 517 if (!document || !document->page()) … … 525 544 { 526 545 URL parsedURL({ }, url); 527 for (Frame* frame = &m_ page.mainFrame(); frame; frame = frame->tree().traverseNext()) {546 for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) { 528 547 if (auto* document = frame->document()) { 529 548 if (auto* page = document->page()) … … 535 554 void InspectorPageAgent::getResourceTree(ErrorString&, RefPtr<Inspector::Protocol::Page::FrameResourceTree>& object) 536 555 { 537 object = buildObjectForFrameTree(&m_ page.mainFrame());556 object = buildObjectForFrameTree(&m_inspectedPage.mainFrame()); 538 557 } 539 558 … … 608 627 JSC::Yarr::RegularExpression regex = ContentSearchUtilities::createSearchRegex(text, caseSensitive, isRegex); 609 628 610 for (Frame* frame = &m_ page.mainFrame(); frame; frame = frame->tree().traverseNext()) {629 for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) { 611 630 for (auto* cachedResource : cachedResourcesForFrame(frame)) { 612 631 if (auto textContent = InspectorNetworkAgent::textContentForCachedResource(*cachedResource)) { … … 663 682 } 664 683 665 Frame& InspectorPageAgent::mainFrame()666 {667 return m_page.mainFrame();668 }669 670 684 Frame* InspectorPageAgent::frameForId(const String& frameId) 671 685 { … … 684 698 } 685 699 686 bool InspectorPageAgent::hasIdForFrame(Frame* frame) const687 {688 return frame && m_frameToIdentifier.contains(frame);689 }690 691 700 String InspectorPageAgent::loaderId(DocumentLoader* loader) 692 701 { … … 698 707 } 699 708 700 Frame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& originRawString)701 {702 for (Frame* frame = &m_page.mainFrame(); frame; frame = frame->tree().traverseNext()) {703 if (frame->document()->securityOrigin().toRawString() == originRawString)704 return frame;705 }706 return nullptr;707 }708 709 709 Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& frameId) 710 710 { … … 715 715 } 716 716 717 DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString& errorString, Frame* frame)718 {719 FrameLoader& frameLoader = frame->loader();720 DocumentLoader* documentLoader = frameLoader.documentLoader();721 if (!documentLoader)722 errorString = "No documentLoader for given frame found"_s;723 return documentLoader;724 }725 726 717 void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader& loader) 727 718 { … … 756 747 void InspectorPageAgent::didPaint(RenderObject& renderer, const LayoutRect& rect) 757 748 { 758 if (!m_ enabled || !m_showPaintRects)749 if (!m_showPaintRects) 759 750 return; 760 751 … … 782 773 m_isFirstLayoutAfterOnLoad = false; 783 774 784 if (!m_enabled)785 return;786 787 775 m_overlay->update(); 788 776 } … … 790 778 void InspectorPageAgent::didScroll() 791 779 { 792 if (m_enabled) 793 m_overlay->update(); 780 m_overlay->update(); 794 781 } 795 782 796 783 void InspectorPageAgent::didRecalculateStyle() 797 784 { 798 if (m_enabled) 799 m_overlay->update(); 785 m_overlay->update(); 800 786 } 801 787 … … 871 857 m_emulatedMedia = media; 872 858 873 m_ page.updateStyleAfterChangeInEnvironment();874 875 if (auto* document = m_ page.mainFrame().document())859 m_inspectedPage.updateStyleAfterChangeInEnvironment(); 860 861 if (auto* document = m_inspectedPage.mainFrame().document()) 876 862 document->updateLayout(); 877 863 } … … 885 871 886 872 if (appearance == "Light"_s) 887 m_ page.setUseDarkAppearanceOverride(false);873 m_inspectedPage.setUseDarkAppearanceOverride(false); 888 874 else if (appearance == "Dark"_s) 889 m_ page.setUseDarkAppearanceOverride(true);875 m_inspectedPage.setUseDarkAppearanceOverride(true); 890 876 else 891 m_ page.setUseDarkAppearanceOverride(WTF::nullopt);877 m_inspectedPage.setUseDarkAppearanceOverride(WTF::nullopt); 892 878 } 893 879 … … 906 892 void InspectorPageAgent::getCompositingBordersVisible(ErrorString&, bool* outParam) 907 893 { 908 *outParam = m_ page.settings().showDebugBorders() || m_page.settings().showRepaintCounter();894 *outParam = m_inspectedPage.settings().showDebugBorders() || m_inspectedPage.settings().showRepaintCounter(); 909 895 } 910 896 911 897 void InspectorPageAgent::setCompositingBordersVisible(ErrorString&, bool visible) 912 898 { 913 m_ page.settings().setShowDebugBorders(visible);914 m_ page.settings().setShowRepaintCounter(visible);899 m_inspectedPage.settings().setShowDebugBorders(visible); 900 m_inspectedPage.settings().setShowRepaintCounter(visible); 915 901 } 916 902 917 903 void InspectorPageAgent::snapshotNode(ErrorString& errorString, int nodeId, String* outDataURL) 918 904 { 919 Frame& frame = mainFrame();920 921 905 InspectorDOMAgent* domAgent = m_instrumentingAgents.inspectorDOMAgent(); 922 906 ASSERT(domAgent); … … 925 909 return; 926 910 927 std::unique_ptr<ImageBuffer> snapshot = WebCore::snapshotNode( frame, *node);911 std::unique_ptr<ImageBuffer> snapshot = WebCore::snapshotNode(m_inspectedPage.mainFrame(), *node); 928 912 if (!snapshot) { 929 913 errorString = "Could not capture snapshot"_s; … … 936 920 void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL) 937 921 { 938 Frame& frame = mainFrame();939 940 922 SnapshotOptions options = SnapshotOptionsNone; 941 923 if (coordinateSystem == "Viewport") … … 943 925 944 926 IntRect rectangle(x, y, width, height); 945 std::unique_ptr<ImageBuffer> snapshot = snapshotFrameRect( frame, rectangle, options);927 std::unique_ptr<ImageBuffer> snapshot = snapshotFrameRect(m_inspectedPage.mainFrame(), rectangle, options); 946 928 947 929 if (!snapshot) { … … 956 938 { 957 939 #if ENABLE(WEB_ARCHIVE) && USE(CF) 958 Frame& frame = mainFrame(); 959 auto archive = LegacyWebArchive::create(frame); 940 auto archive = LegacyWebArchive::create(m_inspectedPage.mainFrame()); 960 941 if (!archive) { 961 942 errorString = "Could not create web archive for main frame"_s; -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h
r242941 r243303 80 80 static void resourceContent(ErrorString&, Frame*, const URL&, String* result, bool* base64Encoded); 81 81 static String sourceMapURLForResource(CachedResource*); 82 83 82 static CachedResource* cachedResource(Frame*, const URL&); 84 83 static Inspector::Protocol::Page::ResourceType resourceTypeJSON(ResourceType); … … 86 85 static ResourceType inspectorResourceType(const CachedResource&); 87 86 static Inspector::Protocol::Page::ResourceType cachedResourceTypeJSON(const CachedResource&); 87 static Frame* findFrameWithSecurityOrigin(Page&, const String& originRawString); 88 static DocumentLoader* assertDocumentLoader(ErrorString&, Frame*); 88 89 89 90 // Page API for InspectorFrontend … … 133 134 134 135 // Cross-agents API 135 Page& page() { return m_page; }136 Frame& mainFrame();137 136 Frame* frameForId(const String& frameId); 138 137 WEBCORE_EXPORT String frameId(Frame*); 139 bool hasIdForFrame(Frame*) const;140 138 String loaderId(DocumentLoader*); 141 Frame* findFrameWithSecurityOrigin(const String& originRawString);142 139 Frame* assertFrame(ErrorString&, const String& frameId); 143 static DocumentLoader* assertDocumentLoader(ErrorString&, Frame*);144 140 145 141 private: … … 155 151 RefPtr<Inspector::PageBackendDispatcher> m_backendDispatcher; 156 152 157 Page& m_ page;153 Page& m_inspectedPage; 158 154 InspectorClient* m_client { nullptr }; 159 155 InspectorOverlay* m_overlay { nullptr }; … … 162 158 HashMap<String, Frame*> m_identifierToFrame; 163 159 HashMap<DocumentLoader*, String> m_loaderToIdentifier; 164 bool m_enabled { false };165 bool m_isFirstLayoutAfterOnLoad { false };166 bool m_showPaintRects { false };167 160 String m_userAgentOverride; 168 161 String m_emulatedMedia; 169 162 String m_forcedAppearance; 163 bool m_isFirstLayoutAfterOnLoad { false }; 164 bool m_showPaintRects { false }; 170 165 }; 171 166 -
trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
r242019 r243303 57 57 using namespace Inspector; 58 58 59 PageDebuggerAgent::PageDebuggerAgent(PageAgentContext& context , InspectorPageAgent* pageAgent)59 PageDebuggerAgent::PageDebuggerAgent(PageAgentContext& context) 60 60 : WebDebuggerAgent(context) 61 , m_page(context.inspectedPage) 62 , m_pageAgent(pageAgent) 61 , m_inspectedPage(context.inspectedPage) 63 62 { 64 63 } … … 82 81 83 82 if (!script.url.isEmpty()) { 84 CachedResource* resource = m_pageAgent->cachedResource(&m_page.mainFrame(), URL({ }, script.url));83 CachedResource* resource = InspectorPageAgent::cachedResource(&m_inspectedPage.mainFrame(), URL({ }, script.url)); 85 84 if (resource) { 86 85 String sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeader); … … 117 116 void PageDebuggerAgent::breakpointActionLog(JSC::ExecState& state, const String& message) 118 117 { 119 m_ pageAgent->page().console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(&state));118 m_inspectedPage.console().addMessage(MessageSource::JS, MessageLevel::Log, message, createScriptCallStack(&state)); 120 119 } 121 120 … … 123 122 { 124 123 if (!executionContextId) { 125 JSC::ExecState* scriptState = mainWorldExecState(&m_ pageAgent->mainFrame());124 JSC::ExecState* scriptState = mainWorldExecState(&m_inspectedPage.mainFrame()); 126 125 return injectedScriptManager().injectedScriptFor(scriptState); 127 126 } -
trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h
r242019 r243303 39 39 class EventListener; 40 40 class EventTarget; 41 class InspectorPageAgent;42 41 class Page; 43 42 class RegisteredEventListener; … … 48 47 WTF_MAKE_FAST_ALLOCATED; 49 48 public: 50 PageDebuggerAgent(PageAgentContext& , InspectorPageAgent*);49 PageDebuggerAgent(PageAgentContext&); 51 50 virtual ~PageDebuggerAgent() = default; 52 51 … … 86 85 Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override; 87 86 88 Page& m_page; 89 90 InspectorPageAgent* m_pageAgent; 87 Page& m_inspectedPage; 91 88 92 89 HashMap<const RegisteredEventListener*, int> m_registeredEventListeners; -
trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp
r241824 r243303 39 39 using namespace Inspector; 40 40 41 PageNetworkAgent::PageNetworkAgent(PageAgentContext& context , InspectorPageAgent* pageAgent)41 PageNetworkAgent::PageNetworkAgent(PageAgentContext& context) 42 42 : InspectorNetworkAgent(context) 43 , m_ pageAgent(pageAgent)43 , m_inspectedPage(context.inspectedPage) 44 44 { 45 ASSERT(m_pageAgent);46 45 } 47 46 48 47 String PageNetworkAgent::loaderIdentifier(DocumentLoader* loader) 49 48 { 50 return m_pageAgent->loaderId(loader); 49 if (loader) { 50 if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent()) 51 return pageAgent->loaderId(loader); 52 } 53 return { }; 51 54 } 52 55 53 56 String PageNetworkAgent::frameIdentifier(DocumentLoader* loader) 54 57 { 55 if (!loader) 56 return { }; 57 return m_pageAgent->frameId(loader->frame()); 58 if (loader) { 59 if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent()) 60 return pageAgent->frameId(loader->frame()); 61 } 62 return { }; 58 63 } 59 64 … … 78 83 // FIXME: <https://webkit.org/b/168475> Web Inspector: Correctly display iframe's WebSockets 79 84 auto* document = downcast<Document>(webSocket->scriptExecutionContext()); 80 if (document->page() != &m_ pageAgent->page())85 if (document->page() != &m_inspectedPage) 81 86 continue; 82 87 … … 89 94 void PageNetworkAgent::setResourceCachingDisabled(bool disabled) 90 95 { 91 m_ pageAgent->page().setResourceCachingDisabledOverride(disabled);96 m_inspectedPage.setResourceCachingDisabledOverride(disabled); 92 97 } 93 98 94 99 ScriptExecutionContext* PageNetworkAgent::scriptExecutionContext(ErrorString& errorString, const String& frameId) 95 100 { 96 auto* frame = m_pageAgent->assertFrame(errorString, frameId); 101 auto* pageAgent = m_instrumentingAgents.inspectorPageAgent(); 102 if (!pageAgent) { 103 errorString = "Missing Page agent"_s; 104 return nullptr; 105 } 106 107 auto* frame = pageAgent->assertFrame(errorString, frameId); 97 108 if (!frame) 98 109 return nullptr; -
trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.h
r225708 r243303 30 30 namespace WebCore { 31 31 32 class Page; 33 32 34 class PageNetworkAgent final : public InspectorNetworkAgent { 33 35 WTF_MAKE_NONCOPYABLE(PageNetworkAgent); 34 36 WTF_MAKE_FAST_ALLOCATED; 35 37 public: 36 PageNetworkAgent(PageAgentContext& , InspectorPageAgent*);38 PageNetworkAgent(PageAgentContext&); 37 39 virtual ~PageNetworkAgent() = default; 38 40 … … 45 47 bool shouldForceBufferingNetworkResourceData() const final { return false; } 46 48 47 InspectorPageAgent* m_pageAgent { nullptr };49 Page& m_inspectedPage; 48 50 }; 49 51
Note: See TracChangeset
for help on using the changeset viewer.