Changeset 243303 in webkit


Ignore:
Timestamp:
Mar 21, 2019 11:22:08 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Page: lazily create the agent
https://bugs.webkit.org/show_bug.cgi?id=195592
<rdar://problem/48791916>

Reviewed by Timothy Hatcher.

No change in functionality.

Have more agents save the inspected Page so they don't need to access it via the
InspectorPageAgent. Make some of InspectorPageAgent's functions static so other
agents can use them without needing to have access to an enabled InspectorPageAgent.

  • inspector/InspectorController.cpp:

(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::createLazyAgents):

  • inspector/agents/InspectorPageAgent.h:

(WebCore::InspectorPageAgent::page): Deleted.

  • inspector/agents/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::InspectorPageAgent):
(WebCore::InspectorPageAgent::enable):
(WebCore::InspectorPageAgent::disable):
(WebCore::InspectorPageAgent::reload):
(WebCore::InspectorPageAgent::navigate):
(WebCore::InspectorPageAgent::overrideSetting):
(WebCore::InspectorPageAgent::getCookies):
(WebCore::InspectorPageAgent::deleteCookie):
(WebCore::InspectorPageAgent::getResourceTree):
(WebCore::InspectorPageAgent::searchInResources):
(WebCore::InspectorPageAgent::didPaint):
(WebCore::InspectorPageAgent::didLayout):
(WebCore::InspectorPageAgent::didScroll):
(WebCore::InspectorPageAgent::didRecalculateStyle):
(WebCore::InspectorPageAgent::setEmulatedMedia):
(WebCore::InspectorPageAgent::setForcedAppearance):
(WebCore::InspectorPageAgent::getCompositingBordersVisible):
(WebCore::InspectorPageAgent::setCompositingBordersVisible):
(WebCore::InspectorPageAgent::snapshotNode):
(WebCore::InspectorPageAgent::snapshotRect):
(WebCore::InspectorPageAgent::archive):
(WebCore::InspectorPageAgent::mainFrame): Deleted.
(WebCore::InspectorPageAgent::hasIdForFrame const): Deleted.

  • inspector/agents/InspectorApplicationCacheAgent.h:
  • inspector/agents/InspectorApplicationCacheAgent.cpp:

(WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent):
(WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus):
(WebCore::InspectorApplicationCacheAgent::getFramesWithManifests):
(WebCore::InspectorApplicationCacheAgent::assertFrameWithDocumentLoader):

  • inspector/agents/InspectorCanvasAgent.h:
  • inspector/agents/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
(WebCore::InspectorCanvasAgent::enable):

  • inspector/agents/InspectorDOMStorageAgent.h:
  • inspector/agents/InspectorDOMStorageAgent.cpp:

(WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
(WebCore::InspectorDOMStorageAgent::findStorageArea):

  • inspector/agents/InspectorIndexedDBAgent.h:
  • inspector/agents/InspectorIndexedDBAgent.cpp:

(WebCore::InspectorIndexedDBAgent::InspectorIndexedDBAgent):
(WebCore::InspectorIndexedDBAgent::requestDatabaseNames):
(WebCore::InspectorIndexedDBAgent::requestDatabase):
(WebCore::InspectorIndexedDBAgent::requestData):
(WebCore::InspectorIndexedDBAgent::clearObjectStore):

  • inspector/agents/page/PageDebuggerAgent.h:
  • inspector/agents/page/PageDebuggerAgent.cpp:

(WebCore::PageDebuggerAgent::PageDebuggerAgent):
(WebCore::PageDebuggerAgent::sourceMapURLForScript):
(WebCore::PageDebuggerAgent::breakpointActionLog):
(WebCore::PageDebuggerAgent::injectedScriptForEval):

  • inspector/agents/page/PageNetworkAgent.h:
  • inspector/agents/page/PageNetworkAgent.cpp:

(WebCore::PageNetworkAgent::PageNetworkAgent):
(WebCore::PageNetworkAgent::loaderIdentifier):
(WebCore::PageNetworkAgent::frameIdentifier):
(WebCore::PageNetworkAgent::setResourceCachingDisabled):
(WebCore::PageNetworkAgent::scriptExecutionContext):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):

Location:
trunk/Source/WebCore
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243298 r243303  
     12019-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
    1892019-03-21  Brent Fulgham  <bfulgham@apple.com>
    290
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r243273 r243303  
    111111    m_agents.append(WTFMove(inspectorAgentPtr));
    112112
    113     auto pageAgentPtr = std::make_unique<InspectorPageAgent>(pageContext, inspectorClient, m_overlay.get());
    114     m_pageAgent = pageAgentPtr.get();
    115     m_agents.append(WTFMove(pageAgentPtr));
    116 
    117113    auto consoleAgent = std::make_unique<PageConsoleAgent>(pageContext);
    118114    m_instrumentingAgents->setWebConsoleAgent(consoleAgent.get());
     
    161157    auto pageContext = pageAgentContext();
    162158
     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
    163163    m_agents.append(std::make_unique<PageRuntimeAgent>(pageContext));
    164164
    165     auto debuggerAgent = std::make_unique<PageDebuggerAgent>(pageContext, m_pageAgent);
     165    auto debuggerAgent = std::make_unique<PageDebuggerAgent>(pageContext);
    166166    auto debuggerAgentPtr = debuggerAgent.get();
    167167    m_agents.append(WTFMove(debuggerAgent));
    168168
    169     m_agents.append(std::make_unique<PageNetworkAgent>(pageContext, m_pageAgent));
     169    m_agents.append(std::make_unique<PageNetworkAgent>(pageContext));
    170170    m_agents.append(std::make_unique<InspectorCSSAgent>(pageContext));
    171171    m_agents.append(std::make_unique<InspectorDOMAgent>(pageContext, m_overlay.get()));
    172172    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));
    174174    m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext));
    175175    m_agents.append(std::make_unique<InspectorWorkerAgent>(pageContext));
     
    177177    m_agents.append(std::make_unique<InspectorDatabaseAgent>(pageContext));
    178178#if ENABLE(INDEXED_DATABASE)
    179     m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext, m_pageAgent));
     179    m_agents.append(std::make_unique<InspectorIndexedDBAgent>(pageContext));
    180180#endif
    181181
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r243269 r243303  
    110110void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world)
    111111{
    112     InspectorPageAgent* pageAgent = instrumentingAgents.inspectorPageAgent();
    113112    if (PageDebuggerAgent* debuggerAgent = instrumentingAgents.pageDebuggerAgent()) {
    114         if (pageAgent && &world == &mainThreadNormalWorld() && &frame == &pageAgent->mainFrame())
     113        if (&world == &mainThreadNormalWorld() && frame.isMainFrame())
    115114            debuggerAgent->didClearMainFrameWindowObject();
    116115    }
     116
    117117    if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent()) {
    118118        if (&world == &mainThreadNormalWorld())
  • trunk/Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.cpp

    r233122 r243303  
    4141using namespace Inspector;
    4242
    43 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(WebAgentContext& context, InspectorPageAgent* pageAgent)
     43InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(PageAgentContext& context)
    4444    : InspectorAgentBase("ApplicationCache"_s, context)
    4545    , m_frontendDispatcher(std::make_unique<Inspector::ApplicationCacheFrontendDispatcher>(context.frontendRouter))
    4646    , m_backendDispatcher(Inspector::ApplicationCacheBackendDispatcher::create(context.backendDispatcher, this))
    47     , m_pageAgent(pageAgent)
     47    , m_inspectedPage(context.inspectedPage)
    4848{
    4949}
     
    6868void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame)
    6969{
     70    auto* pageAgent = m_instrumentingAgents.inspectorPageAgent();
     71    if (!pageAgent)
     72        return;
     73
    7074    if (!frame)
    7175        return;
     76
    7277    auto* documentLoader = frame->loader().documentLoader();
    7378    if (!documentLoader)
     
    7883    auto manifestURL = host.applicationCacheInfo().manifest.string();
    7984
    80     m_frontendDispatcher->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, status);
     85    m_frontendDispatcher->applicationCacheStatusUpdated(pageAgent->frameId(frame), manifestURL, status);
    8186}
    8287
     
    9095    result = JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>::create();
    9196
    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()) {
    93100        auto* documentLoader = frame->loader().documentLoader();
    94101        if (!documentLoader)
     
    99106        if (!manifestURL.isEmpty()) {
    100107            result->addItem(Inspector::Protocol::ApplicationCache::FrameWithManifest::create()
    101                 .setFrameId(m_pageAgent->frameId(frame))
     108                .setFrameId(pageAgent->frameId(frame))
    102109                .setManifestURL(manifestURL)
    103110                .setStatus(static_cast<int>(host.status()))
     
    109116DocumentLoader* InspectorApplicationCacheAgent::assertFrameWithDocumentLoader(ErrorString& errorString, const String& frameId)
    110117{
    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);
    112125    if (!frame)
    113126        return nullptr;
  • trunk/Source/WebCore/inspector/agents/InspectorApplicationCacheAgent.h

    r228218 r243303  
    3838
    3939class Frame;
    40 class InspectorPageAgent;
    4140class Page;
    4241
     
    4746    WTF_MAKE_FAST_ALLOCATED;
    4847public:
    49     InspectorApplicationCacheAgent(WebAgentContext&, InspectorPageAgent*);
     48    InspectorApplicationCacheAgent(PageAgentContext&);
    5049    virtual ~InspectorApplicationCacheAgent() = default;
    5150
     
    5352    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
    5453
     54    // InspectorInstrumentation
    5555    void updateApplicationCacheStatus(Frame*);
    5656    void networkStateChanged();
    5757
     58    // ApplicationCacheBackendDispatcherHandler
    5859    void enable(ErrorString&) override;
    5960    void getFramesWithManifests(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::ApplicationCache::FrameWithManifest>>& result) override;
     
    7071    std::unique_ptr<Inspector::ApplicationCacheFrontendDispatcher> m_frontendDispatcher;
    7172    RefPtr<Inspector::ApplicationCacheBackendDispatcher> m_backendDispatcher;
    72     InspectorPageAgent* m_pageAgent { nullptr };
     73    Page& m_inspectedPage;
    7374};
    7475
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp

    r243029 r243303  
    7272using namespace Inspector;
    7373
    74 InspectorCanvasAgent::InspectorCanvasAgent(WebAgentContext& context)
     74InspectorCanvasAgent::InspectorCanvasAgent(PageAgentContext& context)
    7575    : InspectorAgentBase("Canvas"_s, context)
    7676    , m_frontendDispatcher(std::make_unique<Inspector::CanvasFrontendDispatcher>(context.frontendRouter))
    7777    , m_backendDispatcher(Inspector::CanvasBackendDispatcher::create(context.backendDispatcher, this))
    7878    , m_injectedScriptManager(context.injectedScriptManager)
     79    , m_inspectedPage(context.inspectedPage)
    7980    , m_canvasDestroyedTimer(*this, &InspectorCanvasAgent::canvasDestroyedTimerFired)
    8081    , m_canvasRecordingTimer(*this, &InspectorCanvasAgent::canvasRecordingTimerFired)
     
    112113            return false;
    113114
    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;
    121118    };
    122119
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h

    r242594 r243303  
    6060    WTF_MAKE_FAST_ALLOCATED;
    6161public:
    62     explicit InspectorCanvasAgent(WebAgentContext&);
     62    explicit InspectorCanvasAgent(PageAgentContext&);
    6363    virtual ~InspectorCanvasAgent() = default;
    6464
     
    129129    std::unique_ptr<Inspector::CanvasFrontendDispatcher> m_frontendDispatcher;
    130130    RefPtr<Inspector::CanvasBackendDispatcher> m_backendDispatcher;
     131
    131132    Inspector::InjectedScriptManager& m_injectedScriptManager;
     133    Page& m_inspectedPage;
     134
    132135    HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas;
    133136    Vector<String> m_removedCanvasIdentifiers;
     137    Optional<size_t> m_recordingAutoCaptureFrameCount;
    134138    Timer m_canvasDestroyedTimer;
    135139    Timer m_canvasRecordingTimer;
    136     Optional<size_t> m_recordingAutoCaptureFrameCount;
    137140};
    138141
  • trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp

    r243158 r243303  
    5555using namespace Inspector;
    5656
    57 InspectorDOMStorageAgent::InspectorDOMStorageAgent(WebAgentContext& context)
     57InspectorDOMStorageAgent::InspectorDOMStorageAgent(PageAgentContext& context)
    5858    : InspectorAgentBase("DOMStorage"_s, context)
    5959    , m_frontendDispatcher(std::make_unique<Inspector::DOMStorageFrontendDispatcher>(context.frontendRouter))
    6060    , m_backendDispatcher(Inspector::DOMStorageBackendDispatcher::create(context.backendDispatcher, this))
     61    , m_inspectedPage(context.inspectedPage)
    6162{
    6263}
     
    179180    }
    180181
    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);
    189183    if (!targetFrame) {
    190184        errorString = "Frame not found for the given security origin"_s;
     
    193187
    194188    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());
    197191}
    198192
  • trunk/Source/WebCore/inspector/agents/InspectorDOMStorageAgent.h

    r243158 r243303  
    5252    WTF_MAKE_FAST_ALLOCATED;
    5353public:
    54     InspectorDOMStorageAgent(WebAgentContext&);
     54    InspectorDOMStorageAgent(PageAgentContext&);
    5555    virtual ~InspectorDOMStorageAgent() = default;
    5656
     
    7777    std::unique_ptr<Inspector::DOMStorageFrontendDispatcher> m_frontendDispatcher;
    7878    RefPtr<Inspector::DOMStorageBackendDispatcher> m_backendDispatcher;
     79
     80    Page& m_inspectedPage;
    7981};
    8082
  • trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.cpp

    r241196 r243303  
    520520} // namespace
    521521
    522 InspectorIndexedDBAgent::InspectorIndexedDBAgent(WebAgentContext& context, InspectorPageAgent* pageAgent)
     522InspectorIndexedDBAgent::InspectorIndexedDBAgent(PageAgentContext& context)
    523523    : InspectorAgentBase("IndexedDB"_s, context)
    524524    , m_injectedScriptManager(context.injectedScriptManager)
    525525    , 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}
    531529
    532530void InspectorIndexedDBAgent::didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*)
     
    591589void InspectorIndexedDBAgent::requestDatabaseNames(const String& securityOrigin, Ref<RequestDatabaseNamesCallback>&& callback)
    592590{
    593     Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
     591    auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin);
    594592    Document* document;
    595593    IDBFactory* idbFactory;
     
    613611void InspectorIndexedDBAgent::requestDatabase(const String& securityOrigin, const String& databaseName, Ref<RequestDatabaseCallback>&& callback)
    614612{
    615     Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
     613    auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin);
    616614    Document* document;
    617615    IDBFactory* idbFactory;
     
    625623void 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)
    626624{
    627     Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
     625    auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin);
    628626    Document* document;
    629627    IDBFactory* idbFactory;
     
    736734void InspectorIndexedDBAgent::clearObjectStore(const String& securityOrigin, const String& databaseName, const String& objectStoreName, Ref<ClearObjectStoreCallback>&& callback)
    737735{
    738     Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
     736    auto* frame = InspectorPageAgent::findFrameWithSecurityOrigin(m_inspectedPage, securityOrigin);
    739737    Document* document;
    740738    IDBFactory* idbFactory;
  • trunk/Source/WebCore/inspector/agents/InspectorIndexedDBAgent.h

    r229493 r243303  
    4444namespace WebCore {
    4545
    46 class InspectorPageAgent;
     46class Page;
    4747
    4848typedef String ErrorString;
     
    5252    WTF_MAKE_FAST_ALLOCATED;
    5353public:
    54     InspectorIndexedDBAgent(WebAgentContext&, InspectorPageAgent*);
    55     virtual ~InspectorIndexedDBAgent();
     54    InspectorIndexedDBAgent(PageAgentContext&);
     55    virtual ~InspectorIndexedDBAgent() = default;
    5656
    5757    void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) override;
    5858    void willDestroyFrontendAndBackend(Inspector::DisconnectReason) override;
    5959
    60     // Called from the front-end.
     60    // IndexedDBBackendDispatcherHandler
    6161    void enable(ErrorString&) override;
    6262    void disable(ErrorString&) override;
     
    6969    Inspector::InjectedScriptManager& m_injectedScriptManager;
    7070    RefPtr<Inspector::IndexedDBBackendDispatcher> m_backendDispatcher;
    71     InspectorPageAgent* m_pageAgent { nullptr };
     71
     72    Page& m_inspectedPage;
    7273};
    7374
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp

    r242941 r243303  
    310310}
    311311
     312Frame* 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
     321DocumentLoader* 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
    312330InspectorPageAgent::InspectorPageAgent(PageAgentContext& context, InspectorClient* client, InspectorOverlay* overlay)
    313331    : InspectorAgentBase("Page"_s, context)
    314332    , m_frontendDispatcher(std::make_unique<Inspector::PageFrontendDispatcher>(context.frontendRouter))
    315333    , m_backendDispatcher(Inspector::PageBackendDispatcher::create(context.backendDispatcher, this))
    316     , m_page(context.inspectedPage)
     334    , m_inspectedPage(context.inspectedPage)
    317335    , m_client(client)
    318336    , m_overlay(overlay)
     
    337355void InspectorPageAgent::enable(ErrorString&)
    338356{
    339     m_enabled = true;
     357    if (m_instrumentingAgents.inspectorPageAgent() == this)
     358        return;
     359
    340360    m_instrumentingAgents.setInspectorPageAgent(this);
    341361
     
    345365
    346366#if HAVE(OS_DARK_MODE_SUPPORT)
    347     defaultAppearanceDidChange(m_page.defaultUseDarkAppearance());
     367    defaultAppearanceDidChange(m_inspectedPage.defaultUseDarkAppearance());
    348368#endif
    349369}
     
    351371void InspectorPageAgent::disable(ErrorString&)
    352372{
    353     m_enabled = false;
    354     m_instrumentingAgents.setInspectorPageAgent(nullptr);
    355 
    356373    ErrorString unused;
    357374    setShowPaintRects(unused, false);
     
    362379
    363380#define DISABLE_INSPECTOR_OVERRIDE_SETTING(name) \
    364     m_page.settings().set##name##InspectorOverride(WTF::nullopt);
     381    m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt);
    365382
    366383    FOR_EACH_INSPECTOR_OVERRIDE_SETTING(DISABLE_INSPECTOR_OVERRIDE_SETTING)
    367384
    368385#undef DISABLE_INSPECTOR_OVERRIDE_SETTING
     386
     387    m_instrumentingAgents.setInspectorPageAgent(nullptr);
    369388}
    370389
     
    380399        reloadOptions.add(ReloadOption::ExpiredOnly);
    381400
    382     m_page.mainFrame().loader().reload(reloadOptions);
     401    m_inspectedPage.mainFrame().loader().reload(reloadOptions);
    383402}
    384403
     
    386405{
    387406    UserGestureIndicator indicator { ProcessingUserGesture };
    388     Frame& frame = m_page.mainFrame();
     407    Frame& frame = m_inspectedPage.mainFrame();
    389408
    390409    ResourceRequest resourceRequest { frame.document()->completeURL(url) };
     
    415434    case Inspector::Protocol::Page::Setting::name: { \
    416435        if (value) \
    417             m_page.settings().set##name##InspectorOverride(*value); \
     436            m_inspectedPage.settings().set##name##InspectorOverride(*value); \
    418437        else \
    419             m_page.settings().set##name##InspectorOverride(WTF::nullopt); \
     438            m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt); \
    420439        return; \
    421440    } \
     
    494513    bool rawCookiesImplemented = false;
    495514
    496     for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
     515    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
    497516        Document* document = frame->document();
    498517        if (!document || !document->page())
     
    525544{
    526545    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()) {
    528547        if (auto* document = frame->document()) {
    529548            if (auto* page = document->page())
     
    535554void InspectorPageAgent::getResourceTree(ErrorString&, RefPtr<Inspector::Protocol::Page::FrameResourceTree>& object)
    536555{
    537     object = buildObjectForFrameTree(&m_page.mainFrame());
     556    object = buildObjectForFrameTree(&m_inspectedPage.mainFrame());
    538557}
    539558
     
    608627    JSC::Yarr::RegularExpression regex = ContentSearchUtilities::createSearchRegex(text, caseSensitive, isRegex);
    609628
    610     for (Frame* frame = &m_page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
     629    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
    611630        for (auto* cachedResource : cachedResourcesForFrame(frame)) {
    612631            if (auto textContent = InspectorNetworkAgent::textContentForCachedResource(*cachedResource)) {
     
    663682}
    664683
    665 Frame& InspectorPageAgent::mainFrame()
    666 {
    667     return m_page.mainFrame();
    668 }
    669 
    670684Frame* InspectorPageAgent::frameForId(const String& frameId)
    671685{
     
    684698}
    685699
    686 bool InspectorPageAgent::hasIdForFrame(Frame* frame) const
    687 {
    688     return frame && m_frameToIdentifier.contains(frame);
    689 }
    690 
    691700String InspectorPageAgent::loaderId(DocumentLoader* loader)
    692701{
     
    698707}
    699708
    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 
    709709Frame* InspectorPageAgent::assertFrame(ErrorString& errorString, const String& frameId)
    710710{
     
    715715}
    716716
    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 
    726717void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader& loader)
    727718{
     
    756747void InspectorPageAgent::didPaint(RenderObject& renderer, const LayoutRect& rect)
    757748{
    758     if (!m_enabled || !m_showPaintRects)
     749    if (!m_showPaintRects)
    759750        return;
    760751
     
    782773        m_isFirstLayoutAfterOnLoad = false;
    783774
    784     if (!m_enabled)
    785         return;
    786 
    787775    m_overlay->update();
    788776}
     
    790778void InspectorPageAgent::didScroll()
    791779{
    792     if (m_enabled)
    793         m_overlay->update();
     780    m_overlay->update();
    794781}
    795782
    796783void InspectorPageAgent::didRecalculateStyle()
    797784{
    798     if (m_enabled)
    799         m_overlay->update();
     785    m_overlay->update();
    800786}
    801787
     
    871857    m_emulatedMedia = media;
    872858
    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())
    876862        document->updateLayout();
    877863}
     
    885871
    886872    if (appearance == "Light"_s)
    887         m_page.setUseDarkAppearanceOverride(false);
     873        m_inspectedPage.setUseDarkAppearanceOverride(false);
    888874    else if (appearance == "Dark"_s)
    889         m_page.setUseDarkAppearanceOverride(true);
     875        m_inspectedPage.setUseDarkAppearanceOverride(true);
    890876    else
    891         m_page.setUseDarkAppearanceOverride(WTF::nullopt);
     877        m_inspectedPage.setUseDarkAppearanceOverride(WTF::nullopt);
    892878}
    893879
     
    906892void InspectorPageAgent::getCompositingBordersVisible(ErrorString&, bool* outParam)
    907893{
    908     *outParam = m_page.settings().showDebugBorders() || m_page.settings().showRepaintCounter();
     894    *outParam = m_inspectedPage.settings().showDebugBorders() || m_inspectedPage.settings().showRepaintCounter();
    909895}
    910896
    911897void InspectorPageAgent::setCompositingBordersVisible(ErrorString&, bool visible)
    912898{
    913     m_page.settings().setShowDebugBorders(visible);
    914     m_page.settings().setShowRepaintCounter(visible);
     899    m_inspectedPage.settings().setShowDebugBorders(visible);
     900    m_inspectedPage.settings().setShowRepaintCounter(visible);
    915901}
    916902
    917903void InspectorPageAgent::snapshotNode(ErrorString& errorString, int nodeId, String* outDataURL)
    918904{
    919     Frame& frame = mainFrame();
    920 
    921905    InspectorDOMAgent* domAgent = m_instrumentingAgents.inspectorDOMAgent();
    922906    ASSERT(domAgent);
     
    925909        return;
    926910
    927     std::unique_ptr<ImageBuffer> snapshot = WebCore::snapshotNode(frame, *node);
     911    std::unique_ptr<ImageBuffer> snapshot = WebCore::snapshotNode(m_inspectedPage.mainFrame(), *node);
    928912    if (!snapshot) {
    929913        errorString = "Could not capture snapshot"_s;
     
    936920void InspectorPageAgent::snapshotRect(ErrorString& errorString, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL)
    937921{
    938     Frame& frame = mainFrame();
    939 
    940922    SnapshotOptions options = SnapshotOptionsNone;
    941923    if (coordinateSystem == "Viewport")
     
    943925
    944926    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);
    946928
    947929    if (!snapshot) {
     
    956938{
    957939#if ENABLE(WEB_ARCHIVE) && USE(CF)
    958     Frame& frame = mainFrame();
    959     auto archive = LegacyWebArchive::create(frame);
     940    auto archive = LegacyWebArchive::create(m_inspectedPage.mainFrame());
    960941    if (!archive) {
    961942        errorString = "Could not create web archive for main frame"_s;
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h

    r242941 r243303  
    8080    static void resourceContent(ErrorString&, Frame*, const URL&, String* result, bool* base64Encoded);
    8181    static String sourceMapURLForResource(CachedResource*);
    82 
    8382    static CachedResource* cachedResource(Frame*, const URL&);
    8483    static Inspector::Protocol::Page::ResourceType resourceTypeJSON(ResourceType);
     
    8685    static ResourceType inspectorResourceType(const CachedResource&);
    8786    static Inspector::Protocol::Page::ResourceType cachedResourceTypeJSON(const CachedResource&);
     87    static Frame* findFrameWithSecurityOrigin(Page&, const String& originRawString);
     88    static DocumentLoader* assertDocumentLoader(ErrorString&, Frame*);
    8889
    8990    // Page API for InspectorFrontend
     
    133134
    134135    // Cross-agents API
    135     Page& page() { return m_page; }
    136     Frame& mainFrame();
    137136    Frame* frameForId(const String& frameId);
    138137    WEBCORE_EXPORT String frameId(Frame*);
    139     bool hasIdForFrame(Frame*) const;
    140138    String loaderId(DocumentLoader*);
    141     Frame* findFrameWithSecurityOrigin(const String& originRawString);
    142139    Frame* assertFrame(ErrorString&, const String& frameId);
    143     static DocumentLoader* assertDocumentLoader(ErrorString&, Frame*);
    144140
    145141private:
     
    155151    RefPtr<Inspector::PageBackendDispatcher> m_backendDispatcher;
    156152
    157     Page& m_page;
     153    Page& m_inspectedPage;
    158154    InspectorClient* m_client { nullptr };
    159155    InspectorOverlay* m_overlay { nullptr };
     
    162158    HashMap<String, Frame*> m_identifierToFrame;
    163159    HashMap<DocumentLoader*, String> m_loaderToIdentifier;
    164     bool m_enabled { false };
    165     bool m_isFirstLayoutAfterOnLoad { false };
    166     bool m_showPaintRects { false };
    167160    String m_userAgentOverride;
    168161    String m_emulatedMedia;
    169162    String m_forcedAppearance;
     163    bool m_isFirstLayoutAfterOnLoad { false };
     164    bool m_showPaintRects { false };
    170165};
    171166
  • trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp

    r242019 r243303  
    5757using namespace Inspector;
    5858
    59 PageDebuggerAgent::PageDebuggerAgent(PageAgentContext& context, InspectorPageAgent* pageAgent)
     59PageDebuggerAgent::PageDebuggerAgent(PageAgentContext& context)
    6060    : WebDebuggerAgent(context)
    61     , m_page(context.inspectedPage)
    62     , m_pageAgent(pageAgent)
     61    , m_inspectedPage(context.inspectedPage)
    6362{
    6463}
     
    8281
    8382    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));
    8584        if (resource) {
    8685            String sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeader);
     
    117116void PageDebuggerAgent::breakpointActionLog(JSC::ExecState& state, const String& message)
    118117{
    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));
    120119}
    121120
     
    123122{
    124123    if (!executionContextId) {
    125         JSC::ExecState* scriptState = mainWorldExecState(&m_pageAgent->mainFrame());
     124        JSC::ExecState* scriptState = mainWorldExecState(&m_inspectedPage.mainFrame());
    126125        return injectedScriptManager().injectedScriptFor(scriptState);
    127126    }
  • trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h

    r242019 r243303  
    3939class EventListener;
    4040class EventTarget;
    41 class InspectorPageAgent;
    4241class Page;
    4342class RegisteredEventListener;
     
    4847    WTF_MAKE_FAST_ALLOCATED;
    4948public:
    50     PageDebuggerAgent(PageAgentContext&, InspectorPageAgent*);
     49    PageDebuggerAgent(PageAgentContext&);
    5150    virtual ~PageDebuggerAgent() = default;
    5251
     
    8685    Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override;
    8786
    88     Page& m_page;
    89 
    90     InspectorPageAgent* m_pageAgent;
     87    Page& m_inspectedPage;
    9188
    9289    HashMap<const RegisteredEventListener*, int> m_registeredEventListeners;
  • trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp

    r241824 r243303  
    3939using namespace Inspector;
    4040
    41 PageNetworkAgent::PageNetworkAgent(PageAgentContext& context, InspectorPageAgent* pageAgent)
     41PageNetworkAgent::PageNetworkAgent(PageAgentContext& context)
    4242    : InspectorNetworkAgent(context)
    43     , m_pageAgent(pageAgent)
     43    , m_inspectedPage(context.inspectedPage)
    4444{
    45     ASSERT(m_pageAgent);
    4645}
    4746
    4847String PageNetworkAgent::loaderIdentifier(DocumentLoader* loader)
    4948{
    50     return m_pageAgent->loaderId(loader);
     49    if (loader) {
     50        if (auto* pageAgent = m_instrumentingAgents.inspectorPageAgent())
     51            return pageAgent->loaderId(loader);
     52    }
     53    return { };
    5154}
    5255
    5356String PageNetworkAgent::frameIdentifier(DocumentLoader* loader)
    5457{
    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 { };
    5863}
    5964
     
    7883        // FIXME: <https://webkit.org/b/168475> Web Inspector: Correctly display iframe's WebSockets
    7984        auto* document = downcast<Document>(webSocket->scriptExecutionContext());
    80         if (document->page() != &m_pageAgent->page())
     85        if (document->page() != &m_inspectedPage)
    8186            continue;
    8287
     
    8994void PageNetworkAgent::setResourceCachingDisabled(bool disabled)
    9095{
    91     m_pageAgent->page().setResourceCachingDisabledOverride(disabled);
     96    m_inspectedPage.setResourceCachingDisabledOverride(disabled);
    9297}
    9398
    9499ScriptExecutionContext* PageNetworkAgent::scriptExecutionContext(ErrorString& errorString, const String& frameId)
    95100{
    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);
    97108    if (!frame)
    98109        return nullptr;
  • trunk/Source/WebCore/inspector/agents/page/PageNetworkAgent.h

    r225708 r243303  
    3030namespace WebCore {
    3131
     32class Page;
     33
    3234class PageNetworkAgent final : public InspectorNetworkAgent {
    3335    WTF_MAKE_NONCOPYABLE(PageNetworkAgent);
    3436    WTF_MAKE_FAST_ALLOCATED;
    3537public:
    36     PageNetworkAgent(PageAgentContext&, InspectorPageAgent*);
     38    PageNetworkAgent(PageAgentContext&);
    3739    virtual ~PageNetworkAgent() = default;
    3840
     
    4547    bool shouldForceBufferingNetworkResourceData() const final { return false; }
    4648
    47     InspectorPageAgent* m_pageAgent { nullptr };
     49    Page& m_inspectedPage;
    4850};
    4951
Note: See TracChangeset for help on using the changeset viewer.