Every PageOverlayClientImpl leaks
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / WebPageOverlay.cpp
index db9865cb552c609810551cc97a7608dec11b8f44..9e4086e9c232666b2ab1daf11dd35ad6dd9f8d23 100644 (file)
@@ -42,15 +42,16 @@ static HashMap<PageOverlay*, WebPageOverlay*>& overlayMap()
     return map;
 }
 
-PassRefPtr<WebPageOverlay> WebPageOverlay::create(WebPageOverlay::Client& client, PageOverlay::OverlayType overlayType)
+PassRefPtr<WebPageOverlay> WebPageOverlay::create(std::unique_ptr<WebPageOverlay::Client> client, PageOverlay::OverlayType overlayType)
 {
-    return adoptRef(new WebPageOverlay(client, overlayType));
+    return adoptRef(new WebPageOverlay(WTF::move(client), overlayType));
 }
 
-WebPageOverlay::WebPageOverlay(WebPageOverlay::Client& client, PageOverlay::OverlayType overlayType)
+WebPageOverlay::WebPageOverlay(std::unique_ptr<WebPageOverlay::Client> client, PageOverlay::OverlayType overlayType)
     : m_overlay(PageOverlay::create(*this, overlayType))
-    , m_client(client)
+    , m_client(WTF::move(client))
 {
+    ASSERT(m_client);
     overlayMap().add(m_overlay.get(), this);
 }
 
@@ -90,69 +91,69 @@ void WebPageOverlay::pageOverlayDestroyed(PageOverlay&)
         m_overlay = nullptr;
     }
 
-    m_client.pageOverlayDestroyed(*this);
+    m_client->pageOverlayDestroyed(*this);
 }
 
 void WebPageOverlay::willMoveToPage(PageOverlay&, Page* page)
 {
-    m_client.willMoveToPage(*this, page ? WebPage::fromCorePage(page) : nullptr);
+    m_client->willMoveToPage(*this, page ? WebPage::fromCorePage(page) : nullptr);
 }
 
 void WebPageOverlay::didMoveToPage(PageOverlay&, Page* page)
 {
-    m_client.didMoveToPage(*this, page ? WebPage::fromCorePage(page) : nullptr);
+    m_client->didMoveToPage(*this, page ? WebPage::fromCorePage(page) : nullptr);
 }
 
 void WebPageOverlay::drawRect(PageOverlay&, GraphicsContext& context, const IntRect& dirtyRect)
 {
-    m_client.drawRect(*this, context, dirtyRect);
+    m_client->drawRect(*this, context, dirtyRect);
 }
 
 bool WebPageOverlay::mouseEvent(PageOverlay&, const PlatformMouseEvent& event)
 {
-    return m_client.mouseEvent(*this, event);
+    return m_client->mouseEvent(*this, event);
 }
 
 void WebPageOverlay::didScrollFrame(PageOverlay&, Frame& frame)
 {
-    m_client.didScrollFrame(*this, WebFrame::fromCoreFrame(frame));
+    m_client->didScrollFrame(*this, WebFrame::fromCoreFrame(frame));
 }
 
 #if PLATFORM(MAC)
 DDActionContext *WebPageOverlay::actionContextForResultAtPoint(FloatPoint location, RefPtr<WebCore::Range>& rangeHandle)
 {
-    return m_client.actionContextForResultAtPoint(*this, location, rangeHandle);
+    return m_client->actionContextForResultAtPoint(*this, location, rangeHandle);
 }
 
 void WebPageOverlay::dataDetectorsDidPresentUI()
 {
-    m_client.dataDetectorsDidPresentUI(*this);
+    m_client->dataDetectorsDidPresentUI(*this);
 }
 
 void WebPageOverlay::dataDetectorsDidChangeUI()
 {
-    m_client.dataDetectorsDidChangeUI(*this);
+    m_client->dataDetectorsDidChangeUI(*this);
 }
 
 void WebPageOverlay::dataDetectorsDidHideUI()
 {
-    m_client.dataDetectorsDidHideUI(*this);
+    m_client->dataDetectorsDidHideUI(*this);
 }
 #endif // PLATFORM(MAC)
 
 bool WebPageOverlay::copyAccessibilityAttributeStringValueForPoint(PageOverlay&, String attribute, FloatPoint parameter, String& value)
 {
-    return m_client.copyAccessibilityAttributeStringValueForPoint(*this, attribute, parameter, value);
+    return m_client->copyAccessibilityAttributeStringValueForPoint(*this, attribute, parameter, value);
 }
 
 bool WebPageOverlay::copyAccessibilityAttributeBoolValueForPoint(PageOverlay&, String attribute, FloatPoint parameter, bool& value)
 {
-    return m_client.copyAccessibilityAttributeBoolValueForPoint(*this, attribute, parameter, value);
+    return m_client->copyAccessibilityAttributeBoolValueForPoint(*this, attribute, parameter, value);
 }
 
 Vector<String> WebPageOverlay::copyAccessibilityAttributeNames(PageOverlay&, bool parameterizedNames)
 {
-    return m_client.copyAccessibilityAttributeNames(*this, parameterizedNames);
+    return m_client->copyAccessibilityAttributeNames(*this, parameterizedNames);
 }
 
 } // namespace WebKit