| Index: Source/core/inspector/InspectorFrontendHost.cpp
|
| diff --git a/Source/core/inspector/InspectorFrontendHost.cpp b/Source/core/inspector/InspectorFrontendHost.cpp
|
| index 2e0298dbc86f81a5b36403d8c50f5d6533e65bf7..00e1a125fb3532ebf8bf94bd61e010d95363ad49 100644
|
| --- a/Source/core/inspector/InspectorFrontendHost.cpp
|
| +++ b/Source/core/inspector/InspectorFrontendHost.cpp
|
| @@ -59,28 +59,39 @@ namespace blink {
|
|
|
| class FrontendMenuProvider final : public ContextMenuProvider {
|
| public:
|
| - static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
|
| + static PassRefPtrWillBeRawPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
|
| {
|
| - return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject, items));
|
| + return adoptRefWillBeNoop(new FrontendMenuProvider(frontendHost, frontendApiObject, items));
|
| }
|
|
|
| - void disconnect()
|
| + virtual ~FrontendMenuProvider()
|
| {
|
| - m_frontendApiObject = ScriptValue();
|
| - m_frontendHost = 0;
|
| + // Verify that this menu provider has been detached.
|
| + ASSERT(!m_frontendHost);
|
| }
|
|
|
| -private:
|
| - FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
|
| - : m_frontendHost(frontendHost)
|
| - , m_frontendApiObject(frontendApiObject)
|
| - , m_items(items)
|
| + virtual void trace(Visitor* visitor) override
|
| {
|
| + visitor->trace(m_frontendHost);
|
| + ContextMenuProvider::trace(visitor);
|
| }
|
|
|
| - virtual ~FrontendMenuProvider()
|
| + void disconnect()
|
| {
|
| - contextMenuCleared();
|
| + m_frontendApiObject = ScriptValue();
|
| + m_frontendHost = nullptr;
|
| + }
|
| +
|
| + virtual void contextMenuCleared() override
|
| + {
|
| + if (m_frontendHost) {
|
| + ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared");
|
| + function.call();
|
| +
|
| + m_frontendHost->clearMenuProvider();
|
| + m_frontendHost = nullptr;
|
| + }
|
| + m_items.clear();
|
| }
|
|
|
| virtual void populateContextMenu(ContextMenu* menu) override
|
| @@ -91,37 +102,38 @@ private:
|
|
|
| virtual void contextMenuItemSelected(const ContextMenuItem* item) override
|
| {
|
| - if (m_frontendHost) {
|
| - UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
|
| - int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
|
| + if (!m_frontendHost)
|
| + return;
|
|
|
| - ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSelected");
|
| - function.appendArgument(itemNumber);
|
| - function.call();
|
| - }
|
| + UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
|
| + int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
|
| +
|
| + ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSelected");
|
| + function.appendArgument(itemNumber);
|
| + function.call();
|
| }
|
|
|
| - virtual void contextMenuCleared() override
|
| +private:
|
| + FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items)
|
| + : m_frontendHost(frontendHost)
|
| + , m_frontendApiObject(frontendApiObject)
|
| + , m_items(items)
|
| {
|
| - if (m_frontendHost) {
|
| - ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared");
|
| - function.call();
|
| -
|
| - m_frontendHost->m_menuProvider = 0;
|
| - }
|
| - m_items.clear();
|
| - m_frontendHost = 0;
|
| }
|
|
|
| - InspectorFrontendHost* m_frontendHost;
|
| + RawPtrWillBeMember<InspectorFrontendHost> m_frontendHost;
|
| ScriptValue m_frontendApiObject;
|
| +
|
| + // FIXME: Oilpan: remove when http://crbug.com/424962 Blink GC plugin
|
| + // changes have been deployed. ContextMenuItem triggers looping behavior.
|
| + GC_PLUGIN_IGNORE("crbug.com/424962")
|
| Vector<ContextMenuItem> m_items;
|
| };
|
|
|
| InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Page* frontendPage)
|
| : m_client(client)
|
| , m_frontendPage(frontendPage)
|
| - , m_menuProvider(0)
|
| + , m_menuProvider(nullptr)
|
| {
|
| }
|
|
|
| @@ -133,13 +145,16 @@ InspectorFrontendHost::~InspectorFrontendHost()
|
| void InspectorFrontendHost::trace(Visitor* visitor)
|
| {
|
| visitor->trace(m_frontendPage);
|
| + visitor->trace(m_menuProvider);
|
| }
|
|
|
| void InspectorFrontendHost::disconnectClient()
|
| {
|
| m_client = 0;
|
| - if (m_menuProvider)
|
| + if (m_menuProvider) {
|
| m_menuProvider->disconnect();
|
| + m_menuProvider = nullptr;
|
| + }
|
| m_frontendPage = nullptr;
|
| }
|
|
|
| @@ -216,7 +231,7 @@ void InspectorFrontendHost::showContextMenu(Page* page, float x, float y, const
|
| ScriptValue frontendApiObject = frontendScriptState->getFromGlobalObject("InspectorFrontendAPI");
|
| ASSERT(frontendApiObject.isObject());
|
|
|
| - RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
|
| + RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
|
| m_menuProvider = menuProvider.get();
|
| float zoom = page->deprecatedLocalMainFrame()->pageZoomFactor();
|
| page->inspectorController().showContextMenu(x * zoom, y * zoom, menuProvider);
|
| @@ -239,7 +254,7 @@ void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe
|
| targetPage = window->document()->page();
|
| }
|
|
|
| - RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
|
| + RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, frontendApiObject, items);
|
| targetPage->contextMenuController().showContextMenu(event, menuProvider);
|
| m_menuProvider = menuProvider.get();
|
| }
|
|
|