Commit 9efd2cdf authored by bburg@apple.com's avatar bburg@apple.com

Web Inspector: Page should use std::unique_ptr for InspectorController

https://bugs.webkit.org/show_bug.cgi?id=127068

Reviewed by Joseph Pecoraro.

Source/WebCore:

Make Page and WorkerGlobalScope keep a std::unique_ptr to InspectorController
and WorkerInspectorController. Store page references and return controller
references where possible.

Convert call sites to use an InspectorController reference.
Convert instantiations of InspectorFrontendClient to use std::unique_ptr.
Convert InspectorOverlay to keep Page references.

* WebCore.exp.in:
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::supportsProfiling):
(WebCore::JSDOMWindowBase::supportsRichSourceInfo):
* dom/Node.cpp:
(WebCore::Node::inspect):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::inspectedPageDestroyed):
(WebCore::InspectorController::setInspectorFrontendClient):
(WebCore::InspectorController::hasInspectorFrontendClient):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::disconnectFrontend):
(WebCore::InspectorController::inspectedPage):
(WebCore::InspectorController::developerExtrasEnabled):
* inspector/InspectorController.h:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::canAttachWindow):
(WebCore::InspectorFrontendClientLocal::changeAttachedWindowHeight):
(WebCore::InspectorFrontendClientLocal::changeAttachedWindowWidth):
(WebCore::InspectorFrontendClientLocal::openInNewTab):
(WebCore::InspectorFrontendClientLocal::restoreAttachedWindowHeight):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::InspectorOverlay):
(WebCore::InspectorOverlay::getHighlight):
(WebCore::InspectorOverlay::highlightQuad):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::buildObjectForHighlightedNode):
(WebCore::InspectorOverlay::drawQuadHighlight):
(WebCore::InspectorOverlay::overlayPage):
(WebCore::InspectorOverlay::reset):
* inspector/InspectorOverlay.h:
* inspector/InstrumentingAgents.cpp:
(WebCore::instrumentationForPage): remove null checks.
(WebCore::instrumentationForWorkerGlobalScope): remove null checks.
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::connectFrontend):
(WebCore::WorkerInspectorController::disconnectFrontend):
* inspector/WorkerInspectorController.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenu):
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::populate):
(WebCore::ContextMenuController::addInspectElementItem):
* page/FrameView.cpp:
(WebCore::FrameView::sendResizeEventIfNeeded):
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore::Page::inspectorController):
* page/PageDebuggable.cpp:
(WebCore::PageDebuggable::hasLocalDebugger):
(WebCore::PageDebuggable::parentProcessIdentifier):
(WebCore::PageDebuggable::connect):
(WebCore::PageDebuggable::disconnect):
(WebCore::PageDebuggable::dispatchMessageFromRemoteFrontend):
(WebCore::PageDebuggable::setIndicating):
* platform/graphics/texmap/coordinated/CompositingCoordinator.cpp:
(WebCore::CompositingCoordinator::syncDisplayState):
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::inspectorHighlightRects):
(WebCore::Internals::inspectorHighlightObject):
(WebCore::Internals::emitInspectorDidBeginFrame):
(WebCore::Internals::emitInspectorDidCancelFrame):
(WebCore::Internals::openDummyInspectorFrontend):
(WebCore::Internals::closeDummyInspectorFrontend):
(WebCore::Internals::setInspectorResourcesDataSizeLimits):
(WebCore::Internals::setJavaScriptProfilingEnabled):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
* workers/WorkerGlobalScope.h: remove clearInspector().
(WebCore::WorkerGlobalScope::workerInspectorController):
* workers/WorkerMessagingProxy.cpp:
(WebCore::connectToWorkerGlobalScopeInspectorTask):
(WebCore::disconnectFromWorkerGlobalScopeInspectorTask):
(WebCore::dispatchOnInspectorBackendTask):
* workers/WorkerThread.cpp:
(WebCore::WorkerThreadShutdownFinishTask::performTask):

Source/WebKit/efl:

Convert call sites to use a InspectorController reference.
Convert instantiations of InspectorFrontendClient to use std::unique_ptr.

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::evaluateInWebInspector):
* WebCoreSupport/InspectorClientEfl.cpp:
(WebCore::InspectorClientEfl::openInspectorFrontend):
* ewk/ewk_view.cpp:
(ewk_view_inspector_show):
(ewk_view_inspector_close):

Source/WebKit/gtk:

Convert call sites to use a InspectorController reference.
Convert instantiations of InspectorFrontendClient to use std::unique_ptr.

* WebCoreSupport/ChromeClientGtk.cpp:
(WebKit::paintWebView):
* WebCoreSupport/InspectorClientGtk.cpp:
(WebKit::InspectorClient::openInspectorFrontend):
* webkit/webkitwebinspector.cpp:
(webkit_web_inspector_set_property):
(webkit_web_inspector_get_property):
(webkit_web_inspector_show):
(webkit_web_inspector_inspect_node):
(webkit_web_inspector_inspect_coordinates):
(webkit_web_inspector_close):
(webkit_web_inspector_execute_script):

Source/WebKit/mac:

Convert call sites to use a InspectorController reference.
Convert instantiations of InspectorFrontendClient to use std::unique_ptr.

* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::openInspectorFrontend):
(-[WebInspectorWindowController destroyInspectorView:]):
* WebInspector/WebInspector.mm:
(-[WebInspector showWindow]):
(-[WebInspector isJavaScriptProfilingEnabled]):
(-[WebInspector setJavaScriptProfilingEnabled:]):
(-[WebInspector close:]):
(-[WebInspector evaluateInFrontend:callId:script:]):
* WebInspector/WebNodeHighlighter.mm:
(-[WebNodeHighlighter highlight]):

Source/WebKit/win:

Convert call sites to use a InspectorController reference.

* WebCoreSupport/WebInspectorClient.cpp:
(WebInspectorClient::openInspectorFrontend):
(WebInspectorFrontendClient::destroyInspectorView):
(WebInspectorFrontendClient::onClose):
* WebInspector.cpp:
(WebInspector::show):
(WebInspector::close):
(WebInspector::isJavaScriptProfilingEnabled):
(WebInspector::setJavaScriptProfilingEnabled):
(WebInspector::evaluateInFrontend):
* WebNodeHighlight.cpp:
(WebNodeHighlight::update):

Source/WebKit2:

Convert call sites to use a InspectorController reference.

* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::drawRect):
* WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:
(WebKit::WebInspectorFrontendClient::WebInspectorFrontendClient):
(WebKit::WebInspectorFrontendClient::closeWindow):
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::createInspectorPage):
(WebKit::WebInspector::show):
(WebKit::WebInspector::close):
(WebKit::WebInspector::evaluateScriptForTest):
(WebKit::WebInspector::showConsole):
(WebKit::WebInspector::showResources):
(WebKit::WebInspector::showMainResourceForFrame):
(WebKit::WebInspector::startJavaScriptDebugging):
(WebKit::WebInspector::stopJavaScriptDebugging):
(WebKit::WebInspector::setJavaScriptProfilingEnabled):
(WebKit::WebInspector::startJavaScriptProfiling):
(WebKit::WebInspector::stopJavaScriptProfiling):
(WebKit::WebInspector::startPageProfiling):
(WebKit::WebInspector::stopPageProfiling):
(WebKit::WebInspector::dispatchMessageFromRemoteFrontend):
(WebKit::WebInspector::remoteFrontendConnected):
(WebKit::WebInspector::remoteFrontendDisconnected):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ce799f77
2014-01-18 Brian Burg <bburg@apple.com>
Web Inspector: Page should use std::unique_ptr for InspectorController
https://bugs.webkit.org/show_bug.cgi?id=127068
Reviewed by Joseph Pecoraro.
Make Page and WorkerGlobalScope keep a std::unique_ptr to InspectorController
and WorkerInspectorController. Store page references and return controller
references where possible.
Convert call sites to use an InspectorController reference.
Convert instantiations of InspectorFrontendClient to use std::unique_ptr.
Convert InspectorOverlay to keep Page references.
* WebCore.exp.in:
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::supportsProfiling):
(WebCore::JSDOMWindowBase::supportsRichSourceInfo):
* dom/Node.cpp:
(WebCore::Node::inspect):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::inspectedPageDestroyed):
(WebCore::InspectorController::setInspectorFrontendClient):
(WebCore::InspectorController::hasInspectorFrontendClient):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::disconnectFrontend):
(WebCore::InspectorController::inspectedPage):
(WebCore::InspectorController::developerExtrasEnabled):
* inspector/InspectorController.h:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::canAttachWindow):
(WebCore::InspectorFrontendClientLocal::changeAttachedWindowHeight):
(WebCore::InspectorFrontendClientLocal::changeAttachedWindowWidth):
(WebCore::InspectorFrontendClientLocal::openInNewTab):
(WebCore::InspectorFrontendClientLocal::restoreAttachedWindowHeight):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::InspectorOverlay):
(WebCore::InspectorOverlay::getHighlight):
(WebCore::InspectorOverlay::highlightQuad):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::buildObjectForHighlightedNode):
(WebCore::InspectorOverlay::drawQuadHighlight):
(WebCore::InspectorOverlay::overlayPage):
(WebCore::InspectorOverlay::reset):
* inspector/InspectorOverlay.h:
* inspector/InstrumentingAgents.cpp:
(WebCore::instrumentationForPage): remove null checks.
(WebCore::instrumentationForWorkerGlobalScope): remove null checks.
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::connectFrontend):
(WebCore::WorkerInspectorController::disconnectFrontend):
* inspector/WorkerInspectorController.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::showContextMenu):
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::populate):
(WebCore::ContextMenuController::addInspectElementItem):
* page/FrameView.cpp:
(WebCore::FrameView::sendResizeEventIfNeeded):
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore::Page::inspectorController):
* page/PageDebuggable.cpp:
(WebCore::PageDebuggable::hasLocalDebugger):
(WebCore::PageDebuggable::parentProcessIdentifier):
(WebCore::PageDebuggable::connect):
(WebCore::PageDebuggable::disconnect):
(WebCore::PageDebuggable::dispatchMessageFromRemoteFrontend):
(WebCore::PageDebuggable::setIndicating):
* platform/graphics/texmap/coordinated/CompositingCoordinator.cpp:
(WebCore::CompositingCoordinator::syncDisplayState):
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::inspectorHighlightRects):
(WebCore::Internals::inspectorHighlightObject):
(WebCore::Internals::emitInspectorDidBeginFrame):
(WebCore::Internals::emitInspectorDidCancelFrame):
(WebCore::Internals::openDummyInspectorFrontend):
(WebCore::Internals::closeDummyInspectorFrontend):
(WebCore::Internals::setInspectorResourcesDataSizeLimits):
(WebCore::Internals::setJavaScriptProfilingEnabled):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
* workers/WorkerGlobalScope.h: remove clearInspector().
(WebCore::WorkerGlobalScope::workerInspectorController):
* workers/WorkerMessagingProxy.cpp:
(WebCore::connectToWorkerGlobalScopeInspectorTask):
(WebCore::disconnectFromWorkerGlobalScopeInspectorTask):
(WebCore::dispatchOnInspectorBackendTask):
* workers/WorkerThread.cpp:
(WebCore::WorkerThreadShutdownFinishTask::performTask):
2014-01-18 Anders Carlsson <andersca@apple.com>
Remove ENABLE_THREADED_HTML_PARSER defines everywhere
......@@ -2764,7 +2764,7 @@ __ZN7WebCore19InspectorController15connectFrontendEPN9Inspector24InspectorFronte
__ZN7WebCore19InspectorController18disconnectFrontendEv
__ZN7WebCore19InspectorController18setProfilerEnabledEb
__ZN7WebCore19InspectorController25evaluateForTestInFrontendElRKN3WTF6StringE
__ZN7WebCore19InspectorController26setInspectorFrontendClientEN3WTF10PassOwnPtrINS_23InspectorFrontendClientEEE
__ZN7WebCore19InspectorController26setInspectorFrontendClientENSt3__110unique_ptrINS_23InspectorFrontendClientENS1_14default_deleteIS3_EEEE
__ZN7WebCore19InspectorController39setResourcesDataSizeLimitsFromInternalsEii
__ZN7WebCore19InspectorController4showEv
__ZN7WebCore19InspectorController5closeEv
......
......@@ -117,7 +117,7 @@ bool JSDOMWindowBase::supportsProfiling(const JSGlobalObject* object)
return false;
#if ENABLE(INSPECTOR)
return page->inspectorController()->profilerEnabled();
return page->inspectorController().profilerEnabled();
#else
return false;
#endif // ENABLE(INSPECTOR)
......@@ -139,7 +139,7 @@ bool JSDOMWindowBase::supportsRichSourceInfo(const JSGlobalObject* object)
if (!page)
return false;
bool enabled = page->inspectorController()->enabled();
bool enabled = page->inspectorController().enabled();
ASSERT(enabled || !thisObject->debugger());
ASSERT(enabled || !supportsProfiling(thisObject));
return enabled;
......
......@@ -557,7 +557,7 @@ void Node::inspect()
{
#if ENABLE(INSPECTOR)
if (document().page())
document().page()->inspectorController()->inspect(this);
document().page()->inspectorController().inspect(this);
#endif
}
......
......@@ -82,10 +82,10 @@ using namespace Inspector;
namespace WebCore {
InspectorController::InspectorController(Page* page, InspectorClient* inspectorClient)
InspectorController::InspectorController(Page& page, InspectorClient* inspectorClient)
: m_instrumentingAgents(InstrumentingAgents::create(*this))
, m_injectedScriptManager(std::make_unique<PageInjectedScriptManager>(*this, PageInjectedScriptHost::create()))
, m_overlay(InspectorOverlay::create(page, inspectorClient))
, m_overlay(std::make_unique<InspectorOverlay>(page, inspectorClient))
, m_inspectorFrontendChannel(nullptr)
, m_page(page)
, m_inspectorClient(inspectorClient)
......@@ -101,7 +101,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
m_instrumentingAgents->setInspectorAgent(m_inspectorAgent);
m_agents.append(std::move(inspectorAgentPtr));
auto pageAgentPtr = std::make_unique<InspectorPageAgent>(m_instrumentingAgents.get(), page, inspectorClient, m_overlay.get());
auto pageAgentPtr = std::make_unique<InspectorPageAgent>(m_instrumentingAgents.get(), &page, inspectorClient, m_overlay.get());
InspectorPageAgent* pageAgent = pageAgentPtr.get();
m_pageAgent = pageAgentPtr.get();
m_agents.append(std::move(pageAgentPtr));
......@@ -137,7 +137,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
m_resourceAgent = resourceAgentPtr.get();
m_agents.append(std::move(resourceAgentPtr));
auto runtimeAgentPtr = std::make_unique<PageRuntimeAgent>(m_instrumentingAgents.get(), m_injectedScriptManager.get(), page, pageAgent);
auto runtimeAgentPtr = std::make_unique<PageRuntimeAgent>(m_instrumentingAgents.get(), m_injectedScriptManager.get(), &page, pageAgent);
InspectorRuntimeAgent* runtimeAgent = runtimeAgentPtr.get();
m_agents.append(std::move(runtimeAgentPtr));
......@@ -154,7 +154,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
m_domDebuggerAgent = domDebuggerAgentPtr.get();
m_agents.append(std::move(domDebuggerAgentPtr));
auto profilerAgentPtr = InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent, page, m_injectedScriptManager.get());
auto profilerAgentPtr = InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent, &page, m_injectedScriptManager.get());
m_profilerAgent = profilerAgentPtr.get();
m_agents.append(std::move(profilerAgentPtr));
......@@ -165,7 +165,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
m_agents.append(std::make_unique<InspectorCanvasAgent>(m_instrumentingAgents.get(), pageAgent, m_injectedScriptManager.get()));
m_agents.append(std::make_unique<InspectorInputAgent>(m_instrumentingAgents.get(), page));
m_agents.append(std::make_unique<InspectorInputAgent>(m_instrumentingAgents.get(), &page));
#if USE(ACCELERATED_COMPOSITING)
m_agents.append(std::make_unique<InspectorLayerTreeAgent>(m_instrumentingAgents.get()));
......@@ -195,23 +195,17 @@ InspectorController::~InspectorController()
ASSERT(!m_inspectorClient);
}
PassOwnPtr<InspectorController> InspectorController::create(Page* page, InspectorClient* client)
{
return adoptPtr(new InspectorController(page, client));
}
void InspectorController::inspectedPageDestroyed()
{
disconnectFrontend();
m_injectedScriptManager->disconnect();
m_inspectorClient->inspectorDestroyed();
m_inspectorClient = 0;
m_page = 0;
}
void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient> inspectorFrontendClient)
void InspectorController::setInspectorFrontendClient(std::unique_ptr<InspectorFrontendClient> inspectorFrontendClient)
{
m_inspectorFrontendClient = inspectorFrontendClient;
m_inspectorFrontendClient = std::move(inspectorFrontendClient);
}
bool InspectorController::hasLocalFrontend() const
......@@ -234,7 +228,7 @@ bool InspectorController::hasRemoteFrontend() const
bool InspectorController::hasInspectorFrontendClient() const
{
return m_inspectorFrontendClient;
return m_inspectorFrontendClient.get();
}
void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld& world)
......@@ -268,7 +262,7 @@ void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan
#if ENABLE(REMOTE_INSPECTOR)
if (!m_hasRemoteFrontend)
m_page->remoteInspectorInformationDidChange();
m_page.remoteInspectorInformationDidChange();
#endif
}
......@@ -290,7 +284,7 @@ void InspectorController::disconnectFrontend()
#if ENABLE(REMOTE_INSPECTOR)
if (!m_hasRemoteFrontend)
m_page->remoteInspectorInformationDidChange();
m_page.remoteInspectorInformationDidChange();
#endif
}
......@@ -365,7 +359,7 @@ bool InspectorController::enabled() const
return developerExtrasEnabled();
}
Page* InspectorController::inspectedPage() const
Page& InspectorController::inspectedPage() const
{
return m_page;
}
......@@ -453,10 +447,7 @@ void InspectorController::didComposite()
bool InspectorController::developerExtrasEnabled() const
{
if (!m_page)
return false;
return m_page->settings().developerExtrasEnabled();
return m_page.settings().developerExtrasEnabled();
}
bool InspectorController::canAccessInspectedScriptState(JSC::ExecState* scriptState) const
......
......@@ -77,18 +77,18 @@ class InspectorController final : public Inspector::InspectorEnvironment {
WTF_MAKE_NONCOPYABLE(InspectorController);
WTF_MAKE_FAST_ALLOCATED;
public:
InspectorController(Page&, InspectorClient*);
virtual ~InspectorController();
static PassOwnPtr<InspectorController> create(Page*, InspectorClient*);
void inspectedPageDestroyed();
bool enabled() const;
Page* inspectedPage() const;
Page& inspectedPage() const;
void show();
void close();
void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient>);
void setInspectorFrontendClient(std::unique_ptr<InspectorFrontendClient>);
bool hasInspectorFrontendClient() const;
void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld&);
......@@ -144,13 +144,11 @@ public:
virtual void didCallInjectedScriptFunction() override;
private:
InspectorController(Page*, InspectorClient*);
friend InstrumentingAgents* instrumentationForPage(Page*);
RefPtr<InstrumentingAgents> m_instrumentingAgents;
std::unique_ptr<PageInjectedScriptManager> m_injectedScriptManager;
OwnPtr<InspectorOverlay> m_overlay;
std::unique_ptr<InspectorOverlay> m_overlay;
Inspector::InspectorAgent* m_inspectorAgent;
InspectorDOMAgent* m_domAgent;
......@@ -164,9 +162,9 @@ private:
#endif
RefPtr<Inspector::InspectorBackendDispatcher> m_inspectorBackendDispatcher;
OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
std::unique_ptr<InspectorFrontendClient> m_inspectorFrontendClient;
Inspector::InspectorFrontendChannel* m_inspectorFrontendChannel;
Page* m_page;
Page& m_page;
InspectorClient* m_inspectorClient;
Inspector::InspectorAgentRegistry m_agents;
Vector<InspectorInstrumentationCookie, 2> m_injectedScriptInstrumentationCookies;
......
......@@ -182,8 +182,8 @@ bool InspectorFrontendClientLocal::canAttachWindow()
return true;
// Don't allow the attach if the window would be too small to accommodate the minimum inspector size.
unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
unsigned inspectedPageWidth = m_inspectorController->inspectedPage()->mainFrame().view()->visibleWidth();
unsigned inspectedPageHeight = m_inspectorController->inspectedPage().mainFrame().view()->visibleHeight();
unsigned inspectedPageWidth = m_inspectorController->inspectedPage().mainFrame().view()->visibleWidth();
unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= inspectedPageWidth;
}
......@@ -195,7 +195,7 @@ void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)
void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
{
unsigned totalHeight = m_frontendPage->mainFrame().view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
unsigned totalHeight = m_frontendPage->mainFrame().view()->visibleHeight() + m_inspectorController->inspectedPage().mainFrame().view()->visibleHeight();
unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight);
m_settings->setProperty(inspectorAttachedHeightSetting, String::number(attachedHeight));
setAttachedWindowHeight(attachedHeight);
......@@ -203,7 +203,7 @@ void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
{
unsigned totalWidth = m_frontendPage->mainFrame().view()->visibleWidth() + m_inspectorController->inspectedPage()->mainFrame().view()->visibleWidth();
unsigned totalWidth = m_frontendPage->mainFrame().view()->visibleWidth() + m_inspectorController->inspectedPage().mainFrame().view()->visibleWidth();
unsigned attachedWidth = constrainedAttachedWindowWidth(width, totalWidth);
setAttachedWindowWidth(attachedWidth);
}
......@@ -211,8 +211,7 @@ void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
void InspectorFrontendClientLocal::openInNewTab(const String& url)
{
UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
Page* page = m_inspectorController->inspectedPage();
Frame& mainFrame = page->mainFrame();
Frame& mainFrame = m_inspectorController->inspectedPage().mainFrame();
FrameLoadRequest request(mainFrame.document()->securityOrigin(), ResourceRequest(), "_blank");
bool created;
......@@ -257,7 +256,7 @@ void InspectorFrontendClientLocal::setAttachedWindow(DockSide dockSide)
void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
{
unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
unsigned inspectedPageHeight = m_inspectorController->inspectedPage().mainFrame().view()->visibleHeight();
String value = m_settings->getProperty(inspectorAttachedHeightSetting);
unsigned preferredHeight = value.isEmpty() ? defaultAttachedHeight : value.toUInt();
......
......@@ -228,10 +228,8 @@ static void buildNodeHighlight(Node* node, RenderRegion* region, const Highlight
buildRendererHighlight(renderer, region, highlightConfig, highlight);
}
static void buildQuadHighlight(Page* page, const FloatQuad& quad, const HighlightConfig& highlightConfig, Highlight *highlight)
static void buildQuadHighlight(const FloatQuad& quad, const HighlightConfig& highlightConfig, Highlight *highlight)
{
if (!page)
return;
highlight->setDataFromConfig(highlightConfig);
highlight->type = HighlightTypeRects;
highlight->quads.append(quad);
......@@ -239,7 +237,7 @@ static void buildQuadHighlight(Page* page, const FloatQuad& quad, const Highligh
} // anonymous namespace
InspectorOverlay::InspectorOverlay(Page* page, InspectorClient* client)
InspectorOverlay::InspectorOverlay(Page& page, InspectorClient* client)
: m_page(page)
, m_client(client)
{
......@@ -274,7 +272,7 @@ void InspectorOverlay::getHighlight(Highlight* highlight) const
if (m_highlightNode)
buildNodeHighlight(m_highlightNode.get(), nullptr, m_nodeHighlightConfig, highlight);
else
buildQuadHighlight(m_page, *m_highlightQuad, m_quadHighlightConfig, highlight);
buildQuadHighlight(*m_highlightQuad, m_quadHighlightConfig, highlight);
}
void InspectorOverlay::setPausedInDebuggerMessage(const String* message)
......@@ -300,7 +298,7 @@ void InspectorOverlay::highlightNode(Node* node, const HighlightConfig& highligh
void InspectorOverlay::highlightQuad(PassOwnPtr<FloatQuad> quad, const HighlightConfig& highlightConfig)
{
if (m_quadHighlightConfig.usePageCoordinates)
*quad -= m_page->mainFrame().view()->scrollOffset();
*quad -= m_page.mainFrame().view()->scrollOffset();
m_quadHighlightConfig = highlightConfig;
m_highlightQuad = quad;
......@@ -324,7 +322,7 @@ void InspectorOverlay::update()
return;
}
FrameView* view = m_page->mainFrame().view();
FrameView* view = m_page.mainFrame().view();
if (!view)
return;
......@@ -332,8 +330,8 @@ void InspectorOverlay::update()
IntSize viewportSize = view->visibleContentRect().size();
IntSize frameViewFullSize = view->visibleContentRect(ScrollableArea::IncludeScrollbars).size();
IntSize size = m_size.isEmpty() ? frameViewFullSize : m_size;
overlayPage()->setPageScaleFactor(m_page->pageScaleFactor(), IntPoint());
size.scale(m_page->pageScaleFactor());
overlayPage()->setPageScaleFactor(m_page.pageScaleFactor(), IntPoint());
size.scale(m_page.pageScaleFactor());
overlayView->resize(size);
// Clear canvas and paint things.
......@@ -710,7 +708,7 @@ PassRefPtr<InspectorObject> InspectorOverlay::buildObjectForHighlightedNode() co
RefPtr<InspectorObject> highlightObject = InspectorObject::create();
// The main view's scroll offset is shared across all quads.
FrameView* mainView = m_page->mainFrame().view();
FrameView* mainView = m_page.mainFrame().view();
highlightObject->setObject("scroll", buildObjectForPoint(!mainView->delegatesScrolling() ? mainView->visibleContentRect().location() : FloatPoint()));
highlightObject->setArray("fragments", highlightFragments.release());
......@@ -738,7 +736,7 @@ void InspectorOverlay::drawQuadHighlight()
return;
Highlight highlight;
buildQuadHighlight(m_page, *m_highlightQuad, m_quadHighlightConfig, &highlight);
buildQuadHighlight(*m_highlightQuad, m_quadHighlightConfig, &highlight);
evaluateInOverlay("drawQuadHighlight", buildObjectForHighlight(highlight));
}
......@@ -757,7 +755,7 @@ Page* InspectorOverlay::overlayPage()
fillWithEmptyClients(pageClients);
m_overlayPage = adoptPtr(new Page(pageClients));
Settings& settings = m_page->settings();
Settings& settings = m_page.settings();
Settings& overlaySettings = m_overlayPage->settings();
overlaySettings.setStandardFontFamily(settings.standardFontFamily());
......@@ -798,7 +796,7 @@ Page* InspectorOverlay::overlayPage()
void InspectorOverlay::reset(const IntSize& viewportSize, const IntSize& frameViewFullSize)
{
RefPtr<InspectorObject> resetData = InspectorObject::create();
resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor());
resetData->setNumber("deviceScaleFactor", m_page.deviceScaleFactor());
resetData->setObject("viewportSize", buildObjectForSize(viewportSize));
resetData->setObject("frameViewFullSize", buildObjectForSize(frameViewFullSize));
evaluateInOverlay("reset", resetData.release());
......
......@@ -105,10 +105,7 @@ struct Highlight {
class InspectorOverlay {
WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<InspectorOverlay> create(Page* page, InspectorClient* client)
{
return adoptPtr(new InspectorOverlay(page, client));
}
InspectorOverlay(Page&, InspectorClient*);
~InspectorOverlay();
void update();
......@@ -130,8 +127,6 @@ public:
void freePage();
private:
InspectorOverlay(Page*, InspectorClient*);
void drawGutter();
void drawNodeHighlight();
void drawQuadHighlight();
......@@ -141,7 +136,7 @@ private:
void evaluateInOverlay(const String& method, const String& argument);
void evaluateInOverlay(const String& method, PassRefPtr<Inspector::InspectorValue> argument);
Page* m_page;
Page& m_page;
InspectorClient* m_client;
String m_pausedInDebuggerMessage;
RefPtr<Node> m_highlightNode;
......
......@@ -105,16 +105,12 @@ void InstrumentingAgents::reset()
InstrumentingAgents* instrumentationForPage(Page* page)
{
ASSERT(isMainThread());
if (InspectorController* controller = page->inspectorController())
return controller->m_instrumentingAgents.get();
return 0;
return page ? page->inspectorController().m_instrumentingAgents.get() : nullptr;
}
InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope* workerGlobalScope)
{
if (WorkerInspectorController* controller = workerGlobalScope->workerInspectorController())
return controller->m_instrumentingAgents.get();
return 0;
return workerGlobalScope ? workerGlobalScope->workerInspectorController().m_instrumentingAgents.get() : nullptr;
}
} // namespace WebCore
......
......@@ -55,7 +55,6 @@
#include "WorkerRuntimeAgent.h"
#include "WorkerThread.h"
#include <inspector/InspectorBackendDispatcher.h>
#include <wtf/PassOwnPtr.h>
using namespace Inspector;
......@@ -66,36 +65,37 @@ namespace {
class PageInspectorProxy : public InspectorFrontendChannel {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit PageInspectorProxy(WorkerGlobalScope* workerGlobalScope) : m_workerGlobalScope(workerGlobalScope) { }
explicit PageInspectorProxy(WorkerGlobalScope& workerGlobalScope)
: m_workerGlobalScope(workerGlobalScope) { }
virtual ~PageInspectorProxy() { }
private:
virtual bool sendMessageToFrontend(const String& message)
{
m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageInspector(message);
m_workerGlobalScope.thread()->workerReportingProxy().postMessageToPageInspector(message);
return true;
}
WorkerGlobalScope* m_workerGlobalScope;
WorkerGlobalScope& m_workerGlobalScope;
};
}
WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGlobalScope)
WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope& workerGlobalScope)
: m_workerGlobalScope(workerGlobalScope)
, m_instrumentingAgents(InstrumentingAgents::create(*this))
, m_injectedScriptManager(std::make_unique<PageInjectedScriptManager>(*this, PageInjectedScriptHost::create()))
, m_runtimeAgent(0)
, m_runtimeAgent(nullptr)
{
auto runtimeAgent = std::make_unique<WorkerRuntimeAgent>(m_instrumentingAgents.get(), m_injectedScriptManager.get(), workerGlobalScope);
auto runtimeAgent = std::make_unique<WorkerRuntimeAgent>(m_instrumentingAgents.get(), m_injectedScriptManager.get(), &workerGlobalScope);
m_runtimeAgent = runtimeAgent.get();
m_agents.append(std::move(runtimeAgent));
auto consoleAgent = std::make_unique<WorkerConsoleAgent>(m_instrumentingAgents.get(), m_injectedScriptManager.get());
#if ENABLE(JAVASCRIPT_DEBUGGER)
auto debuggerAgent = std::make_unique<WorkerDebuggerAgent>(m_instrumentingAgents.get(), workerGlobalScope, m_injectedScriptManager.get());
auto debuggerAgent = std::make_unique<WorkerDebuggerAgent>(m_instrumentingAgents.get(), &workerGlobalScope, m_injectedScriptManager.get());
m_runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer());
m_agents.append(std::move(debuggerAgent));
m_agents.append(InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent.get(), workerGlobalScope, m_injectedScriptManager.get()));
m_agents.append(InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent.get(), &workerGlobalScope, m_injectedScriptManager.get()));
m_agents.append(std::make_unique<InspectorHeapProfilerAgent>(m_instrumentingAgents.get(), m_injectedScriptManager.get()));
#endif
m_agents.append(std::make_unique<InspectorTimelineAgent>(m_instrumentingAgents.get(), nullptr, nullptr, InspectorTimelineAgent::WorkerInspector, nullptr));
......@@ -122,7 +122,7 @@ WorkerInspectorController::~WorkerInspectorController()
void WorkerInspectorController::connectFrontend()
{
ASSERT(!m_frontendChannel);
m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerGlobalScope));
m_frontendChannel = std::make_unique<PageInspectorProxy>(m_workerGlobalScope);
m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.get());
m_agents.didCreateFrontendAndBackend(m_frontendChannel.get(), m_backendDispatcher.get());
}
......@@ -134,7 +134,7 @@ void WorkerInspectorController::disconnectFrontend()
m_agents.willDestroyFrontendAndBackend();
m_backendDispatcher->clearFrontend();
m_backendDispatcher.clear();
m_frontendChannel.clear();
m_frontendChannel = nullptr;
}
void WorkerInspectorController::dispatchMessageFromFrontend(const String& message)
......
......@@ -40,7 +40,6 @@
#include <wtf/FastMalloc.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
......@@ -60,7 +59,7 @@ class WorkerInspectorController final : public Inspector::InspectorEnvironment {
WTF_MAKE_NONCOPYABLE(WorkerInspectorController);
WTF_MAKE_FAST_ALLOCATED;
public:
WorkerInspectorController(WorkerGlobalScope*);
explicit WorkerInspectorController(WorkerGlobalScope&);
~WorkerInspectorController();
void connectFrontend();
......@@ -80,12 +79,12 @@ public:
private:
friend InstrumentingAgents* instrumentationForWorkerGlobalScope(WorkerGlobalScope*);
WorkerGlobalScope* m_workerGlobalScope;
WorkerGlobalScope& m_workerGlobalScope;
RefPtr<InstrumentingAgents> m_instrumentingAgents;
std::unique_ptr<PageInjectedScriptManager> m_injectedScriptManager;
InspectorRuntimeAgent* m_runtimeAgent;
Inspector::InspectorAgentRegistry m_agents;
OwnPtr<InspectorFrontendChannel> m_frontendChannel;
std::unique_ptr<InspectorFrontendChannel> m_frontendChannel;
RefPtr<Inspector::InspectorBackendDispatcher> m_backendDispatcher;
Vector<InspectorInstrumentationCookie, 2> m_injectedScriptInstrumentationCookies;
};
......
......@@ -2956,7 +2956,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
if (Page* page = m_frame.page()) {
if (m_frame.isMainFrame())
page->inspectorController()->resume();
page->inspectorController().resume();
}
#endif