WeakPtrFactory should populate m_ref lazily.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Sep 2017 04:38:45 +0000 (04:38 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Sep 2017 04:38:45 +0000 (04:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177375

Reviewed by Geoffrey Garen.

Source/WebCore:

* Modules/encryptedmedia/CDM.cpp:
(WebCore::CDM::CDM):
* Modules/encryptedmedia/CDM.h:
(WebCore::CDM::createWeakPtr):
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
(WebCore::MediaKeySession::generateRequest):
(WebCore::MediaKeySession::load):
(WebCore::MediaKeySession::update):
(WebCore::MediaKeySession::close):
(WebCore::MediaKeySession::remove):
* Modules/encryptedmedia/MediaKeys.cpp:
(WebCore::MediaKeys::MediaKeys):
(WebCore::MediaKeys::createSession):
* Modules/mediastream/MediaDevices.cpp:
(WebCore::MediaDevices::MediaDevices):
* Modules/mediastream/MediaDevices.h:
(WebCore::MediaDevices::createWeakPtr):
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack):
* Modules/mediastream/MediaStreamTrack.h:
(WebCore::MediaStreamTrack::createWeakPtr):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::AccessibilityRenderObject):
* accessibility/AccessibilityRenderObject.h:
(WebCore::AccessibilityRenderObject::createWeakPtr):
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::WebAnimation):
* animation/WebAnimation.h:
* css/FontFace.cpp:
(WebCore::FontFace::FontFace):
(WebCore::FontFace::createWeakPtr):
(WebCore::FontFace::createWeakPtr const): Deleted.
* css/FontFace.h:
* css/StyleSheetContents.h:
* dom/DataTransferItemList.cpp:
(WebCore::DataTransferItemList::DataTransferItemList):
(WebCore::DataTransferItemList::add):
(WebCore::DataTransferItemList::ensureItems const):
(WebCore::DataTransferItemList::didSetStringData):
* dom/Document.cpp:
(WebCore::Document::postTask):
* dom/Document.h:
(WebCore::Document::createWeakPtr):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::createWeakPtr):
* html/HTMLPictureElement.h:
* html/parser/HTMLResourcePreloader.h:
(WebCore::HTMLResourcePreloader::HTMLResourcePreloader):
(WebCore::HTMLResourcePreloader::createWeakPtr):
* loader/LinkLoader.cpp:
(WebCore::LinkLoader::LinkLoader):
* loader/LinkLoader.h:
(WebCore::LinkLoader::createWeakPtr):
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::MediaResourceLoader):
* loader/MediaResourceLoader.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::DOMWindow):
* page/DOMWindow.h:
* platform/GenericTaskQueue.cpp:
(WebCore::TaskDispatcher<Timer>::TaskDispatcher):
(WebCore::TaskDispatcher<Timer>::postTask):
* platform/GenericTaskQueue.h:
(WebCore::GenericTaskQueue::GenericTaskQueue):
(WebCore::GenericTaskQueue::enqueueTask):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::createWeakPtr):
* platform/Scrollbar.cpp:
(WebCore::Scrollbar::Scrollbar):
* platform/Scrollbar.h:
(WebCore::Scrollbar::createWeakPtr):
* platform/Widget.h:
(WebCore::Widget::createWeakPtr):
* platform/audio/mac/AudioHardwareListenerMac.cpp:
(WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac):
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::FontCascade):
* platform/graphics/FontCascade.h:
(WebCore::FontCascade::createWeakPtr const):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
(WebCore::MediaPlayerPrivateAVFoundation::createWeakPtr):
* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
(WebCore::CDMSessionAVFoundationObjC::createWeakPtr):
* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
(WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC):
* platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
(WebCore::CDMSessionAVStreamSession::CDMSessionAVStreamSession):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createWeakPtr):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sizeWillChangeAtTime):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::append):
(WebCore::SourceBufferPrivateAVFObjC::abort):
* platform/graphics/cv/TextureCacheCV.mm:
(WebCore::TextureCacheCV::TextureCacheCV):
(WebCore::TextureCacheCV::textureFromImage):
* platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
(WebCore::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
(WebCore::DisplayRefreshMonitorMac::displayLinkFired):
* platform/ios/RemoteCommandListenerIOS.h:
(WebCore::RemoteCommandListenerIOS::createWeakPtr):
* platform/ios/RemoteCommandListenerIOS.mm:
(WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS):
* platform/mac/RemoteCommandListenerMac.h:
(WebCore::RemoteCommandListenerMac::createWeakPtr):
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::MediaStreamPrivate):
* platform/mediastream/MediaStreamPrivate.h:
(WebCore::MediaStreamPrivate::createWeakPtr):
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::RealtimeMediaSource):
* platform/mediastream/RealtimeMediaSource.h:
* platform/mock/MockMediaEndpoint.cpp:
(WebCore::MockMediaEndpoint::MockMediaEndpoint):
(WebCore::MockMediaEndpoint::generateDtlsInfo):
* rendering/RenderMultiColumnSpannerPlaceholder.cpp:
(WebCore::RenderMultiColumnSpannerPlaceholder::RenderMultiColumnSpannerPlaceholder):
* rendering/RenderMultiColumnSpannerPlaceholder.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::RenderView):
* rendering/RenderView.h:
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::RenderWidget):
* rendering/RenderWidget.h:
(WebCore::RenderWidget::createWeakPtr):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::RootInlineBox):
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::createWeakPtr):
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::SVGPathElement):
* svg/SVGPathElement.h:
* svg/properties/SVGMatrixTearOff.h:
* testing/MockCDMFactory.cpp:
(WebCore::MockCDMFactory::MockCDMFactory):
(WebCore::MockCDMFactory::createCDM):
(WebCore::MockCDM::MockCDM):
(WebCore::MockCDM::createInstance):
(WebCore::m_weakPtrFactory): Deleted.

Source/WebCore/PAL:

* pal/system/mac/SystemSleepListenerMac.mm:
(PAL::SystemSleepListenerMac::SystemSleepListenerMac):

Source/WebKit:

* UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy):
(WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard):
(WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):
* UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
* UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::ApplicationStateTracker):
* UIProcess/Cocoa/WebViewImpl.h:
(WebKit::WebViewImpl::createWeakPtr):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::WebViewImpl):
* UIProcess/Launcher/ProcessLauncher.cpp:
(WebKit::ProcessLauncher::ProcessLauncher):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/ProcessAssertion.h:
(WebKit::ProcessAssertion::createWeakPtr):
* UIProcess/WebPageProxy.cpp:
(WebKit::m_configurationPreferenceValues):
(WebKit::m_weakPtrFactory): Deleted.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::createWeakPtr const):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
(WebKit::RemoteLayerTreeDrawingArea::createWeakPtr):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::WebEditorClient):
(WebEditorClient::requestCandidatesForSelection):

Source/WTF:

This helps us with the overhead of initializing WeakPtrFactory for
objects that rarely end up creating the weak reference.
-This is in preparation for introducing WeakPtr to RenderObject.

All credit to Geoffrey Garen.

* wtf/WeakPtr.h:
(WTF::WeakReference::get const):
(WTF::WeakReference::clear):
(WTF::WeakReference::WeakReference):
(WTF::WeakPtrFactory::~WeakPtrFactory):
(WTF::WeakPtrFactory::createWeakPtr const):
(WTF::WeakPtrFactory::revokeAll):
(WTF::WeakPtrFactory::WeakPtrFactory): Deleted.

Tools:

* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222422 268f45cc-cd09-0410-ab3c-d52691b4dbfc

103 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/WeakPtr.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/CDM.cpp
Source/WebCore/Modules/encryptedmedia/CDM.h
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp
Source/WebCore/Modules/mediastream/MediaDevices.cpp
Source/WebCore/Modules/mediastream/MediaDevices.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.mm
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h
Source/WebCore/animation/WebAnimation.cpp
Source/WebCore/animation/WebAnimation.h
Source/WebCore/css/FontFace.cpp
Source/WebCore/css/FontFace.h
Source/WebCore/css/StyleSheetContents.h
Source/WebCore/dom/DataTransferItemList.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLPictureElement.h
Source/WebCore/html/parser/HTMLResourcePreloader.h
Source/WebCore/loader/LinkLoader.cpp
Source/WebCore/loader/LinkLoader.h
Source/WebCore/loader/MediaResourceLoader.cpp
Source/WebCore/loader/MediaResourceLoader.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/platform/GenericTaskQueue.cpp
Source/WebCore/platform/GenericTaskQueue.h
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/Scrollbar.cpp
Source/WebCore/platform/Scrollbar.h
Source/WebCore/platform/Widget.h
Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp
Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp
Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp
Source/WebCore/platform/graphics/FontCascade.cpp
Source/WebCore/platform/graphics/FontCascade.h
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/graphics/cv/TextureCacheCV.mm
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp
Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
Source/WebCore/platform/ios/RemoteCommandListenerIOS.h
Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm
Source/WebCore/platform/mac/RemoteCommandListenerMac.h
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mock/MockMediaEndpoint.cpp
Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.cpp
Source/WebCore/rendering/RenderMultiColumnSpannerPlaceholder.h
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RenderView.h
Source/WebCore/rendering/RenderWidget.cpp
Source/WebCore/rendering/RenderWidget.h
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/RootInlineBox.h
Source/WebCore/svg/SVGPathElement.cpp
Source/WebCore/svg/SVGPathElement.h
Source/WebCore/svg/properties/SVGMatrixTearOff.h
Source/WebCore/testing/MockCDMFactory.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp
Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm
Source/WebKit/UIProcess/ApplicationStateTracker.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/Launcher/ProcessLauncher.cpp
Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit/UIProcess/ProcessAssertion.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp
Source/WebKit/UIProcess/gtk/WaylandCompositor.h
Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp

index cacd823..7f4d0bf 100644 (file)
@@ -1,3 +1,25 @@
+2017-09-22  Zalan Bujtas  <zalan@apple.com>
+
+        WeakPtrFactory should populate m_ref lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=177375
+
+        Reviewed by Geoffrey Garen.
+
+        This helps us with the overhead of initializing WeakPtrFactory for
+        objects that rarely end up creating the weak reference.
+        -This is in preparation for introducing WeakPtr to RenderObject.
+
+        All credit to Geoffrey Garen.
+
+        * wtf/WeakPtr.h:
+        (WTF::WeakReference::get const):
+        (WTF::WeakReference::clear):
+        (WTF::WeakReference::WeakReference):
+        (WTF::WeakPtrFactory::~WeakPtrFactory):
+        (WTF::WeakPtrFactory::createWeakPtr const):
+        (WTF::WeakPtrFactory::revokeAll):
+        (WTF::WeakPtrFactory::WeakPtrFactory): Deleted.
+
 2017-09-21  Alex Christensen  <achristensen@webkit.org>
 
         Make StringBuilder movable
index 29cc056..bd2f544 100644 (file)
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/Threading.h>
 
-#if USE(WEB_THREAD)
-#include <wtf/MainThread.h>
-#endif
-
 namespace WTF {
 
 template<typename T> class WeakPtr;
@@ -47,25 +43,9 @@ class WeakReference : public ThreadSafeRefCounted<WeakReference<T>> {
     WTF_MAKE_NONCOPYABLE(WeakReference<T>);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    T* get() const
-    {
-#if USE(WEB_THREAD)
-        ASSERT(canAccessThreadLocalDataForThread(m_boundThread));
-#else
-        ASSERT(m_boundThread == currentThread());
-#endif
-        return m_ptr;
-    }
+    T* get() const { return m_ptr; }
 
-    void clear()
-    {
-#if USE(WEB_THREAD)
-        ASSERT(canAccessThreadLocalDataForThread(m_boundThread));
-#else
-        ASSERT(m_boundThread == currentThread());
-#endif
-        m_ptr = nullptr;
-    }
+    void clear() { m_ptr = nullptr; }
 
 private:
     friend class WeakPtr<T>;
@@ -75,16 +55,10 @@ private:
 
     explicit WeakReference(T* ptr)
         : m_ptr(ptr)
-#ifndef NDEBUG
-        , m_boundThread(currentThread())
-#endif
     {
     }
 
     T* m_ptr;
-#ifndef NDEBUG
-    ThreadIdentifier m_boundThread;
-#endif
 };
 
 template<typename T>
@@ -118,23 +92,33 @@ class WeakPtrFactory {
     WTF_MAKE_NONCOPYABLE(WeakPtrFactory<T>);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit WeakPtrFactory(T* ptr) : m_ref(WeakReference<T>::create(ptr)) { }
-
-    ~WeakPtrFactory() { m_ref->clear(); }
+    WeakPtrFactory() = default;
+    ~WeakPtrFactory()
+    {
+        if (!m_ref)
+            return;
+        m_ref->clear();
+    }
 
-    // We should consider having createWeakPtr populate m_ref the first time createWeakPtr is called.
-    WeakPtr<T> createWeakPtr() const { return WeakPtr<T>(m_ref.copyRef()); }
+    WeakPtr<T> createWeakPtr(T& ptr) const
+    {
+        if (!m_ref)
+            m_ref = WeakReference<T>::create(&ptr);
+        ASSERT(&ptr == m_ref->get());
+        return WeakPtr<T>(Ref<WeakReference<T>>(*m_ref));
+    }
 
     void revokeAll()
     {
-        T* ptr = m_ref->get();
+        if (!m_ref)
+            return;
+
         m_ref->clear();
-        // We create a new WeakReference so that future calls to createWeakPtr() create nonzero WeakPtrs.
-        m_ref = WeakReference<T>::create(ptr);
+        m_ref = nullptr;
     }
 
 private:
-    Ref<WeakReference<T>> m_ref;
+    mutable RefPtr<WeakReference<T>> m_ref;
 };
 
 template<typename T, typename U> inline bool operator==(const WeakPtr<T>& a, const WeakPtr<U>& b)
index 0852a6b..2d44b72 100644 (file)
@@ -1,3 +1,166 @@
+2017-09-22  Zalan Bujtas  <zalan@apple.com>
+
+        WeakPtrFactory should populate m_ref lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=177375
+
+        Reviewed by Geoffrey Garen.
+
+        * Modules/encryptedmedia/CDM.cpp:
+        (WebCore::CDM::CDM):
+        * Modules/encryptedmedia/CDM.h:
+        (WebCore::CDM::createWeakPtr):
+        * Modules/encryptedmedia/MediaKeySession.cpp:
+        (WebCore::MediaKeySession::MediaKeySession):
+        (WebCore::MediaKeySession::generateRequest):
+        (WebCore::MediaKeySession::load):
+        (WebCore::MediaKeySession::update):
+        (WebCore::MediaKeySession::close):
+        (WebCore::MediaKeySession::remove):
+        * Modules/encryptedmedia/MediaKeys.cpp:
+        (WebCore::MediaKeys::MediaKeys):
+        (WebCore::MediaKeys::createSession):
+        * Modules/mediastream/MediaDevices.cpp:
+        (WebCore::MediaDevices::MediaDevices):
+        * Modules/mediastream/MediaDevices.h:
+        (WebCore::MediaDevices::createWeakPtr):
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::MediaStreamTrack):
+        * Modules/mediastream/MediaStreamTrack.h:
+        (WebCore::MediaStreamTrack::createWeakPtr):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::AccessibilityRenderObject):
+        * accessibility/AccessibilityRenderObject.h:
+        (WebCore::AccessibilityRenderObject::createWeakPtr):
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::WebAnimation):
+        * animation/WebAnimation.h:
+        * css/FontFace.cpp:
+        (WebCore::FontFace::FontFace):
+        (WebCore::FontFace::createWeakPtr):
+        (WebCore::FontFace::createWeakPtr const): Deleted.
+        * css/FontFace.h:
+        * css/StyleSheetContents.h:
+        * dom/DataTransferItemList.cpp:
+        (WebCore::DataTransferItemList::DataTransferItemList):
+        (WebCore::DataTransferItemList::add):
+        (WebCore::DataTransferItemList::ensureItems const):
+        (WebCore::DataTransferItemList::didSetStringData):
+        * dom/Document.cpp:
+        (WebCore::Document::postTask):
+        * dom/Document.h:
+        (WebCore::Document::createWeakPtr):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::createWeakPtr):
+        * html/HTMLPictureElement.h:
+        * html/parser/HTMLResourcePreloader.h:
+        (WebCore::HTMLResourcePreloader::HTMLResourcePreloader):
+        (WebCore::HTMLResourcePreloader::createWeakPtr):
+        * loader/LinkLoader.cpp:
+        (WebCore::LinkLoader::LinkLoader):
+        * loader/LinkLoader.h:
+        (WebCore::LinkLoader::createWeakPtr):
+        * loader/MediaResourceLoader.cpp:
+        (WebCore::MediaResourceLoader::MediaResourceLoader):
+        * loader/MediaResourceLoader.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::DOMWindow):
+        * page/DOMWindow.h:
+        * platform/GenericTaskQueue.cpp:
+        (WebCore::TaskDispatcher<Timer>::TaskDispatcher):
+        (WebCore::TaskDispatcher<Timer>::postTask):
+        * platform/GenericTaskQueue.h:
+        (WebCore::GenericTaskQueue::GenericTaskQueue):
+        (WebCore::GenericTaskQueue::enqueueTask):
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::createWeakPtr):
+        * platform/Scrollbar.cpp:
+        (WebCore::Scrollbar::Scrollbar):
+        * platform/Scrollbar.h:
+        (WebCore::Scrollbar::createWeakPtr):
+        * platform/Widget.h:
+        (WebCore::Widget::createWeakPtr):
+        * platform/audio/mac/AudioHardwareListenerMac.cpp:
+        (WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac):
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::FontCascade):
+        * platform/graphics/FontCascade.h:
+        (WebCore::FontCascade::createWeakPtr const):
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+        (WebCore::MediaPlayerPrivateAVFoundation::createWeakPtr):
+        * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
+        (WebCore::CDMSessionAVFoundationObjC::createWeakPtr):
+        * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
+        (WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC):
+        * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
+        (WebCore::CDMSessionAVStreamSession::CDMSessionAVStreamSession):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createWeakPtr):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sizeWillChangeAtTime):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
+        (WebCore::SourceBufferPrivateAVFObjC::append):
+        (WebCore::SourceBufferPrivateAVFObjC::abort):
+        * platform/graphics/cv/TextureCacheCV.mm:
+        (WebCore::TextureCacheCV::TextureCacheCV):
+        (WebCore::TextureCacheCV::textureFromImage):
+        * platform/graphics/mac/DisplayRefreshMonitorMac.cpp:
+        (WebCore::DisplayRefreshMonitorMac::DisplayRefreshMonitorMac):
+        (WebCore::DisplayRefreshMonitorMac::displayLinkFired):
+        * platform/ios/RemoteCommandListenerIOS.h:
+        (WebCore::RemoteCommandListenerIOS::createWeakPtr):
+        * platform/ios/RemoteCommandListenerIOS.mm:
+        (WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS):
+        * platform/mac/RemoteCommandListenerMac.h:
+        (WebCore::RemoteCommandListenerMac::createWeakPtr):
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::MediaStreamPrivate):
+        * platform/mediastream/MediaStreamPrivate.h:
+        (WebCore::MediaStreamPrivate::createWeakPtr):
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::RealtimeMediaSource):
+        * platform/mediastream/RealtimeMediaSource.h:
+        * platform/mock/MockMediaEndpoint.cpp:
+        (WebCore::MockMediaEndpoint::MockMediaEndpoint):
+        (WebCore::MockMediaEndpoint::generateDtlsInfo):
+        * rendering/RenderMultiColumnSpannerPlaceholder.cpp:
+        (WebCore::RenderMultiColumnSpannerPlaceholder::RenderMultiColumnSpannerPlaceholder):
+        * rendering/RenderMultiColumnSpannerPlaceholder.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::RenderView):
+        * rendering/RenderView.h:
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::RenderWidget):
+        * rendering/RenderWidget.h:
+        (WebCore::RenderWidget::createWeakPtr):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::RootInlineBox):
+        * rendering/RootInlineBox.h:
+        (WebCore::RootInlineBox::createWeakPtr):
+        * svg/SVGPathElement.cpp:
+        (WebCore::SVGPathElement::SVGPathElement):
+        * svg/SVGPathElement.h:
+        * svg/properties/SVGMatrixTearOff.h:
+        * testing/MockCDMFactory.cpp:
+        (WebCore::MockCDMFactory::MockCDMFactory):
+        (WebCore::MockCDMFactory::createCDM):
+        (WebCore::MockCDM::MockCDM):
+        (WebCore::MockCDM::createInstance):
+        (WebCore::m_weakPtrFactory): Deleted.
+
 2017-09-22  Tim Horton  <timothy_horton@apple.com>
 
         Add env() as an alias of constant()
index 60e8aad..b740bb0 100644 (file)
@@ -59,7 +59,6 @@ Ref<CDM> CDM::create(Document& document, const String& keySystem)
 CDM::CDM(Document& document, const String& keySystem)
     : ContextDestructionObserver(&document)
     , m_keySystem(keySystem)
-    , m_weakPtrFactory(this)
 {
     ASSERT(supportsKeySystem(keySystem));
     for (auto* factory : CDMFactory::registeredFactories()) {
index 46d53ad..97a4c55 100644 (file)
@@ -99,7 +99,7 @@ private:
     std::optional<MediaKeySystemConfiguration>  getSupportedConfiguration(const MediaKeySystemConfiguration& candidateConfiguration, MediaKeysRestrictions&);
     std::optional<Vector<MediaKeySystemMediaCapability>> getSupportedCapabilitiesForAudioVideoType(AudioVideoType, const Vector<MediaKeySystemMediaCapability>& requestedCapabilities, const MediaKeySystemConfiguration& partialConfiguration, MediaKeysRestrictions&);
 
-    WeakPtr<CDM> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<CDM> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     using ConsentStatusCallback = WTF::Function<void(ConsentStatus, MediaKeySystemConfiguration&&, MediaKeysRestrictions&&)>;
     void getConsentStatus(MediaKeySystemConfiguration&& accumulatedConfiguration, MediaKeysRestrictions&&, ConsentStatusCallback&&);
index cbd94c0..4d8245c 100644 (file)
@@ -62,7 +62,6 @@ MediaKeySession::MediaKeySession(ScriptExecutionContext& context, WeakPtr<MediaK
     , m_implementation(WTFMove(implementation))
     , m_instance(WTFMove(instance))
     , m_eventQueue(*this)
-    , m_weakPtrFactory(this)
 {
     // https://w3c.github.io/encrypted-media/#dom-mediakeys-setservercertificate
     // W3C Editor's Draft 09 November 2016
@@ -189,7 +188,7 @@ void MediaKeySession::generateRequest(const AtomicString& initDataType, const Bu
             m_latestDecryptTime = 0;
         }
 
-        m_instance->requestLicense(m_sessionType, initDataType, WTFMove(initData), [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable {
+        m_instance->requestLicense(m_sessionType, initDataType, WTFMove(initData), [this, weakThis = m_weakPtrFactory.createWeakPtr(*this), promise = WTFMove(promise)] (Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable {
             if (!weakThis)
                 return;
 
@@ -282,7 +281,7 @@ void MediaKeySession::load(const String& sessionId, Ref<DeferredPromise>&& promi
         // 8.6. Let message type be null.
         // 8.7. Let cdm be the CDM instance represented by this object's cdm instance value.
         // 8.8. Use the cdm to execute the following steps:
-        m_instance->loadSession(m_sessionType, *sanitizedSessionId, origin, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise), sanitizedSessionId = *sanitizedSessionId] (std::optional<CDMInstance::KeyStatusVector>&& knownKeys, std::optional<double>&& expiration, std::optional<CDMInstance::Message>&& message, CDMInstance::SuccessValue succeeded, CDMInstance::SessionLoadFailure failure) mutable {
+        m_instance->loadSession(m_sessionType, *sanitizedSessionId, origin, [this, weakThis = m_weakPtrFactory.createWeakPtr(*this), promise = WTFMove(promise), sanitizedSessionId = *sanitizedSessionId] (std::optional<CDMInstance::KeyStatusVector>&& knownKeys, std::optional<double>&& expiration, std::optional<CDMInstance::Message>&& message, CDMInstance::SuccessValue succeeded, CDMInstance::SessionLoadFailure failure) mutable {
             // 8.8.1. If there is no data stored for the sanitized session ID in the origin, resolve promise with false and abort these steps.
             // 8.8.2. If the stored session's session type is not the same as the current MediaKeySession session type, reject promise with a newly created TypeError.
             // 8.8.3. Let session data be the data stored for the sanitized session ID in the origin. This must not include data from other origin(s) or that is not associated with an origin.
@@ -383,7 +382,7 @@ void MediaKeySession::update(const BufferSource& response, Ref<DeferredPromise>&
         // 6.5. Let session closed be false.
         // 6.6. Let cdm be the CDM instance represented by this object's cdm instance value.
         // 6.7. Use the cdm to execute the following steps:
-        m_instance->updateLicense(m_sessionId, m_sessionType, *sanitizedResponse, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (bool sessionWasClosed, std::optional<CDMInstance::KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<CDMInstance::Message>&& message, CDMInstance::SuccessValue succeeded) mutable {
+        m_instance->updateLicense(m_sessionId, m_sessionType, *sanitizedResponse, [this, weakThis = m_weakPtrFactory.createWeakPtr(*this), promise = WTFMove(promise)] (bool sessionWasClosed, std::optional<CDMInstance::KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<CDMInstance::Message>&& message, CDMInstance::SuccessValue succeeded) mutable {
             if (!weakThis)
                 return;
 
@@ -495,7 +494,7 @@ void MediaKeySession::close(Ref<DeferredPromise>&& promise)
     m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
         // 5.1. Let cdm be the CDM instance represented by session's cdm instance value.
         // 5.2. Use cdm to close the key session associated with session.
-        m_instance->closeSession(m_sessionId, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] () mutable {
+        m_instance->closeSession(m_sessionId, [this, weakThis = m_weakPtrFactory.createWeakPtr(*this), promise = WTFMove(promise)] () mutable {
             if (!weakThis)
                 return;
 
@@ -533,7 +532,7 @@ void MediaKeySession::remove(Ref<DeferredPromise>&& promise)
         // 4.3. Let message type be null.
 
         // 4.4. Use the cdm to execute the following steps:
-        m_instance->removeSessionData(m_sessionId, m_sessionType, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (CDMInstance::KeyStatusVector&& keys, std::optional<Ref<SharedBuffer>>&& message, CDMInstance::SuccessValue succeeded) mutable {
+        m_instance->removeSessionData(m_sessionId, m_sessionType, [this, weakThis = m_weakPtrFactory.createWeakPtr(*this), promise = WTFMove(promise)] (CDMInstance::KeyStatusVector&& keys, std::optional<Ref<SharedBuffer>>&& message, CDMInstance::SuccessValue succeeded) mutable {
             if (!weakThis)
                 return;
 
index c0ef554..bef36a3 100644 (file)
@@ -45,7 +45,6 @@ MediaKeys::MediaKeys(bool useDistinctiveIdentifier, bool persistentStateAllowed,
     , m_supportedSessionTypes(supportedSessionTypes)
     , m_implementation(WTFMove(implementation))
     , m_instance(WTFMove(instance))
-    , m_weakPtrFactory(this)
 {
 }
 
@@ -68,7 +67,7 @@ ExceptionOr<Ref<MediaKeySession>> MediaKeys::createSession(ScriptExecutionContex
     // 3. Let session be a new MediaKeySession object, and initialize it as follows:
     // NOTE: Continued in MediaKeySession.
     // 4. Return session.
-    auto session = MediaKeySession::create(context, m_weakPtrFactory.createWeakPtr(), sessionType, m_useDistinctiveIdentifier, m_implementation.copyRef(), m_instance.copyRef());
+    auto session = MediaKeySession::create(context, m_weakPtrFactory.createWeakPtr(*this), sessionType, m_useDistinctiveIdentifier, m_implementation.copyRef(), m_instance.copyRef());
     m_sessions.append(session.copyRef());
     return WTFMove(session);
 }
index 6e40c7f..4405996 100644 (file)
@@ -47,7 +47,6 @@ namespace WebCore {
 inline MediaDevices::MediaDevices(Document& document)
     : ContextDestructionObserver(&document)
     , m_scheduledEventTimer(*this, &MediaDevices::scheduledEventTimerFired)
-    , m_weakPtrFactory(this)
 {
     m_deviceChangedToken = RealtimeMediaSourceCenter::singleton().addDevicesChangedObserver([weakThis = createWeakPtr(), this]() {
 
index 9f30c3e..6112853 100644 (file)
@@ -82,7 +82,7 @@ private:
     void refEventTarget() override { ref(); }
     void derefEventTarget() override { deref(); }
 
-    WeakPtr<MediaDevices> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaDevices> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     Timer m_scheduledEventTimer;
     std::optional<RealtimeMediaSourceCenter::DevicesChangedObserverToken> m_deviceChangedToken;
index 16884e3..9e178df 100644 (file)
@@ -53,7 +53,6 @@ Ref<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext& context,
 MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
     : ActiveDOMObject(&context)
     , m_private(WTFMove(privateTrack))
-    , m_weakPtrFactory(this)
     , m_taskQueue(context)
 {
     suspendIfNeeded();
index 4a4994a..a53acd6 100644 (file)
@@ -165,7 +165,7 @@ private:
     void trackSettingsChanged(MediaStreamTrackPrivate&) final;
     void trackEnabledChanged(MediaStreamTrackPrivate&) final;
 
-    WeakPtr<MediaStreamTrack> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaStreamTrack> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     Vector<Observer*> m_observers;
     Ref<MediaStreamTrackPrivate> m_private;
index 69880c1..a25cee8 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-22  Zalan Bujtas  <zalan@apple.com>
+
+        WeakPtrFactory should populate m_ref lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=177375
+
+        Reviewed by Geoffrey Garen.
+
+        * pal/system/mac/SystemSleepListenerMac.mm:
+        (PAL::SystemSleepListenerMac::SystemSleepListenerMac):
+
 2017-09-21  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
 
         [PAL] Move MediaTimeAVFoundation into PAL
index 0b5a0f5..6d53a7b 100644 (file)
@@ -40,14 +40,13 @@ std::unique_ptr<SystemSleepListener> SystemSleepListener::create(Client& client)
 
 SystemSleepListenerMac::SystemSleepListenerMac(Client& client)
     : SystemSleepListener(client)
-    , m_weakPtrFactory(this)
     , m_sleepObserver(nil)
     , m_wakeObserver(nil)
 {
     NSNotificationCenter *center = [[NSWorkspace sharedWorkspace] notificationCenter];
     NSOperationQueue *queue = [NSOperationQueue mainQueue];
 
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
 
     m_sleepObserver = [center addObserverForName:NSWorkspaceWillSleepNotification object:nil queue:queue usingBlock:^(NSNotification *) {
         callOnMainThread([weakThis] {
index d2de1f3..e4155d1 100644 (file)
@@ -109,7 +109,6 @@ using namespace HTMLNames;
 AccessibilityRenderObject::AccessibilityRenderObject(RenderObject* renderer)
     : AccessibilityNodeObject(renderer->node())
     , m_renderer(renderer)
-    , m_weakPtrFactory(this)
 {
 #ifndef NDEBUG
     m_renderer->setHasAXObject(true);
index 8953ecd..a507157 100644 (file)
@@ -200,7 +200,7 @@ public:
 
     String passwordFieldValue() const override;
     
-    WeakPtr<AccessibilityRenderObject> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<AccessibilityRenderObject> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 protected:
     explicit AccessibilityRenderObject(RenderObject*);
index 00661ce..dbc5566 100644 (file)
@@ -60,7 +60,6 @@ RefPtr<WebAnimation> WebAnimation::create(AnimationEffect* effect, AnimationTime
 WebAnimation::WebAnimation(AnimationEffect* effect, AnimationTimeline* timeline)
     : m_effect(effect)
     , m_timeline(timeline)
-    , m_weakPtrFactory(this)
 {
     if (m_effect)
         m_effect->setAnimation(this);
index b0173b6..d6fb0a0 100644 (file)
@@ -48,7 +48,7 @@ public:
     AnimationEffect* effect() const { return m_effect.get(); }
     AnimationTimeline* timeline() const { return m_timeline.get(); }
 
-    WeakPtr<WebAnimation> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<WebAnimation> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     WebAnimation(AnimationEffect*, AnimationTimeline*);
index 82531ff..966b7fa 100644 (file)
@@ -120,16 +120,14 @@ Ref<FontFace> FontFace::create(CSSFontFace& face)
 }
 
 FontFace::FontFace(CSSFontSelector& fontSelector)
-    : m_weakPtrFactory(this)
-    , m_backing(CSSFontFace::create(&fontSelector, nullptr, this))
+    : m_backing(CSSFontFace::create(&fontSelector, nullptr, this))
     , m_loadedPromise(*this, &FontFace::loadedPromiseResolve)
 {
     m_backing->addClient(*this);
 }
 
 FontFace::FontFace(CSSFontFace& face)
-    : m_weakPtrFactory(this)
-    , m_backing(face)
+    : m_backing(face)
     , m_loadedPromise(*this, &FontFace::loadedPromiseResolve)
 {
     m_backing->addClient(*this);
@@ -140,9 +138,9 @@ FontFace::~FontFace()
     m_backing->removeClient(*this);
 }
 
-WeakPtr<FontFace> FontFace::createWeakPtr() const
+WeakPtr<FontFace> FontFace::createWeakPtr()
 {
-    return m_weakPtrFactory.createWeakPtr();
+    return m_weakPtrFactory.createWeakPtr(*this);
 }
 
 RefPtr<CSSValue> FontFace::parseString(const String& string, CSSPropertyID propertyID)
index c71ce03..2f4c889 100644 (file)
@@ -85,7 +85,7 @@ public:
 
     void fontStateChanged(CSSFontFace&, CSSFontFace::Status oldState, CSSFontFace::Status newState) final;
 
-    WeakPtr<FontFace> createWeakPtr() const;
+    WeakPtr<FontFace> createWeakPtr();
 
     void ref() final { RefCounted::ref(); }
     void deref() final { RefCounted::deref(); }
index 1907558..8c0b4da 100644 (file)
@@ -143,7 +143,7 @@ public:
 
     void shrinkToFit();
 
-    WeakPtr<StyleSheetContents> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<StyleSheetContents> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     WEBCORE_EXPORT StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext&);
@@ -175,7 +175,7 @@ private:
 
     Vector<CSSStyleSheet*> m_clients;
     
-    WeakPtrFactory<StyleSheetContents> m_weakPtrFactory { this };
+    WeakPtrFactory<StyleSheetContents> m_weakPtrFactory;
 };
 
 } // namespace WebCore
index 6f6c0fa..75c67e0 100644 (file)
@@ -41,8 +41,7 @@ static bool isSupportedType(const String& type)
 }
 
 DataTransferItemList::DataTransferItemList(DataTransfer& dataTransfer)
-    : m_weakPtrFactory(this)
-    , m_dataTransfer(dataTransfer)
+    : m_dataTransfer(dataTransfer)
 {
 }
 
@@ -81,7 +80,7 @@ ExceptionOr<RefPtr<DataTransferItem>> DataTransferItemList::add(const String& da
 
     m_dataTransfer.pasteboard().writeString(lowercasedType, data);
     ASSERT(m_items);
-    m_items->append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(), lowercasedType));
+    m_items->append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*this), lowercasedType));
     return RefPtr<DataTransferItem> { m_items->last().copyRef() };
 }
 
@@ -129,13 +128,13 @@ Vector<Ref<DataTransferItem>>& DataTransferItemList::ensureItems() const
     for (auto& type : m_dataTransfer.types()) {
         auto lowercasedType = type.convertToASCIILowercase();
         if (isSupportedType(lowercasedType))
-            items.append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(), lowercasedType));
+            items.append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*const_cast<DataTransferItemList*>(this)), lowercasedType));
     }
 
     for (auto& file : m_dataTransfer.files().files()) {
         auto type = File::contentTypeForFile(file->path()).convertToASCIILowercase();
         if (isSupportedType(type) || file->isDirectory())
-            items.append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(), type, file.copyRef()));
+            items.append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*const_cast<DataTransferItemList*>(this)), type, file.copyRef()));
     }
 
     m_items = WTFMove(items);
@@ -181,7 +180,7 @@ void DataTransferItemList::didSetStringData(const String& type)
     String lowercasedType = type.convertToASCIILowercase();
     removeStringItemOfLowercasedType(*m_items, type.convertToASCIILowercase());
 
-    m_items->append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(), lowercasedType));
+    m_items->append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*this), lowercasedType));
 }
 
 }
index cee3a2c..2845149 100644 (file)
@@ -469,7 +469,6 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_constantPropertyMap(std::make_unique<ConstantPropertyMap>(*this))
     , m_documentClasses(documentClasses)
     , m_eventQueue(*this)
-    , m_weakFactory(this)
 #if ENABLE(FULLSCREEN_API)
     , m_fullScreenChangeDelayTimer(*this, &Document::fullScreenChangeDelayTimerFired)
 #endif
@@ -5627,7 +5626,7 @@ void Document::addMessage(MessageSource source, MessageLevel level, const String
 
 void Document::postTask(Task&& task)
 {
-    callOnMainThread([documentReference = m_weakFactory.createWeakPtr(), task = WTFMove(task)]() mutable {
+    callOnMainThread([documentReference = m_weakFactory.createWeakPtr(*this), task = WTFMove(task)]() mutable {
         ASSERT(isMainThread());
 
         Document* document = documentReference.get();
index e0095fe..7a5d1ae 100644 (file)
@@ -1272,7 +1272,7 @@ public:
     bool isCapturing() const { return MediaProducer::isCapturing(m_mediaState); }
     WEBCORE_EXPORT void updateIsPlayingMedia(uint64_t = HTMLMediaElementInvalidID);
     void pageMutedStateDidChange();
-    WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<Document> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     void addPlaybackTargetPickerClient(MediaPlaybackTargetClient&);
index f122c07..1700bd6 100644 (file)
@@ -411,7 +411,6 @@ static uint64_t nextLogIdentifier()
 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& document, bool createdByParser)
     : HTMLElement(tagName, document)
     , ActiveDOMObject(&document)
-    , m_weakFactory(this)
     , m_pendingActionTimer(*this, &HTMLMediaElement::pendingActionTimerFired)
     , m_progressEventTimer(*this, &HTMLMediaElement::progressEventTimerFired)
     , m_playbackProgressTimer(*this, &HTMLMediaElement::playbackProgressTimerFired)
index c33ab9b..c8418f1 100644 (file)
@@ -145,7 +145,7 @@ class HTMLMediaElement
 #endif
 {
 public:
-    WeakPtr<HTMLMediaElement> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<HTMLMediaElement> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
     MediaPlayer* player() const { return m_player.get(); }
 
     virtual bool isVideo() const { return false; }
index 84bd66e..0cb4781 100644 (file)
@@ -43,14 +43,14 @@ public:
 
     bool viewportChangeAffectedPicture() const;
 
-    WeakPtr<HTMLPictureElement> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<HTMLPictureElement> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
 private:
     HTMLPictureElement(const QualifiedName&, Document&);
 
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
 
-    WeakPtrFactory<HTMLPictureElement> m_weakFactory { this };
+    WeakPtrFactory<HTMLPictureElement> m_weakFactory;
     Vector<MediaQueryResult> m_viewportDependentMediaQueryResults;
 };
 
index cd10f85..aa2c782 100644 (file)
@@ -77,14 +77,13 @@ class HTMLResourcePreloader {
 public:
     explicit HTMLResourcePreloader(Document& document)
         : m_document(document)
-        , m_weakFactory(this)
     {
     }
 
     void preload(PreloadRequestStream);
     void preload(std::unique_ptr<PreloadRequest>);
 
-    WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
 private:
     Document& m_document;
index 72795b0..2b16132 100644 (file)
@@ -57,7 +57,6 @@ namespace WebCore {
 
 LinkLoader::LinkLoader(LinkLoaderClient& client)
     : m_client(client)
-    , m_weakPtrFactory(this)
 {
 }
 
index de3aea7..1755f61 100644 (file)
@@ -58,7 +58,7 @@ public:
     static void loadLinksFromHeader(const String& headerValue, const URL& baseURL, Document&, MediaAttributeCheck);
     static bool isSupportedType(CachedResource::Type, const String& mimeType);
 
-    WeakPtr<LinkLoader> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<LinkLoader> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
     void triggerEvents(const CachedResource&);
     void cancelLoad();
 
index c407a7c..b2e1605 100644 (file)
@@ -45,7 +45,6 @@ MediaResourceLoader::MediaResourceLoader(Document& document, HTMLMediaElement& m
     , m_document(&document)
     , m_mediaElement(mediaElement.createWeakPtr())
     , m_crossOriginMode(crossOriginMode)
-    , m_weakFactory(this)
 {
 }
 
index 5a10bf3..b004b7a 100644 (file)
@@ -58,7 +58,7 @@ public:
     Vector<ResourceResponse> responsesForTesting() const { return m_responsesForTesting; }
     void addResponseForTesting(const ResourceResponse&);
 
-    WeakPtr<const MediaResourceLoader> createWeakPtr() const { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<const MediaResourceLoader> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
 private:
     void contextDestroyed() override;
index 92f5b90..87ba9d8 100644 (file)
@@ -394,7 +394,6 @@ void DOMWindow::setCanShowModalDialogOverride(bool allow)
 DOMWindow::DOMWindow(Document& document)
     : ContextDestructionObserver(&document)
     , FrameDestructionObserver(document.frame())
-    , m_weakPtrFactory(this)
 {
     ASSERT(frame());
     addLanguageChangeObserver(this, &languagesChangedCallback);
index ab327bd..d6d4d18 100644 (file)
@@ -325,7 +325,7 @@ public:
     void enableSuddenTermination();
     void disableSuddenTermination();
 
-    WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     explicit DOMWindow(Document&);
index 0a65520..ab08862 100644 (file)
 namespace WebCore {
 
 TaskDispatcher<Timer>::TaskDispatcher()
-    : m_weakPtrFactory(this)
 {
 }
 
 void TaskDispatcher<Timer>::postTask(Function<void()>&& function)
 {
     m_pendingTasks.append(WTFMove(function));
-    pendingDispatchers().append(m_weakPtrFactory.createWeakPtr());
+    pendingDispatchers().append(m_weakPtrFactory.createWeakPtr(*this));
     if (!sharedTimer().isActive())
         sharedTimer().startOneShot(0_s);
 }
index 5d6498c..02c0ab9 100644 (file)
@@ -70,14 +70,12 @@ template <typename T>
 class GenericTaskQueue {
 public:
     GenericTaskQueue()
-        : m_weakPtrFactory(this)
-        , m_dispatcher()
+        : m_dispatcher()
     {
     }
 
     GenericTaskQueue(T& t)
-        : m_weakPtrFactory(this)
-        , m_dispatcher(t)
+        : m_dispatcher(t)
     {
     }
 
@@ -89,7 +87,7 @@ public:
             return;
 
         ++m_pendingTasks;
-        auto weakThis = m_weakPtrFactory.createWeakPtr();
+        auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
         m_dispatcher.postTask([weakThis, task = WTFMove(task)] {
             if (!weakThis)
                 return;
index 4b820fe..14b6561 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&);
 
-    WeakPtr<ScrollableArea> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<ScrollableArea> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 #if ENABLE(CSS_SCROLL_SNAP)
     WEBCORE_EXPORT const Vector<LayoutUnit>* horizontalSnapOffsets() const;
@@ -354,7 +354,7 @@ private:
 
     mutable std::unique_ptr<ScrollAnimator> m_scrollAnimator;
 
-    WeakPtrFactory<ScrollableArea> m_weakPtrFactory { this };
+    WeakPtrFactory<ScrollableArea> m_weakPtrFactory;
 
 #if ENABLE(CSS_SCROLL_SNAP)
     std::unique_ptr<ScrollSnapOffsetsInfo<LayoutUnit>> m_snapOffsetsInfo;
index 050d4d9..9ee9381 100644 (file)
@@ -77,7 +77,6 @@ Scrollbar::Scrollbar(ScrollableArea& scrollableArea, ScrollbarOrientation orient
     , m_suppressInvalidation(false)
     , m_isAlphaLocked(false)
     , m_isCustomScrollbar(isCustomScrollbar)
-    , m_weakPtrFactory(this)
 {
     theme().registerScrollbar(*this);
 
index e256081..1a86bf3 100644 (file)
@@ -133,7 +133,7 @@ public:
 
     bool supportsUpdateOnSecondaryThread() const;
 
-    WeakPtr<Scrollbar> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<Scrollbar> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 protected:
     Scrollbar(ScrollableArea&, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0, bool isCustomScrollbar = false);
index 710ef7b..b5c674a 100644 (file)
@@ -193,7 +193,7 @@ public:
     WEBCORE_EXPORT virtual IntPoint convertToContainingView(const IntPoint&) const;
     WEBCORE_EXPORT virtual IntPoint convertFromContainingView(const IntPoint&) const;
 
-    WeakPtr<Widget> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<Widget> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     void init(PlatformWidget); // Must be called by all Widget constructors to initialize cross-platform data.
@@ -216,7 +216,7 @@ private:
 #else
     RetainPtr<NSView> m_widget;
 #endif
-    WeakPtrFactory<Widget> m_weakPtrFactory { this };
+    WeakPtrFactory<Widget> m_weakPtrFactory;
     bool m_selfVisible;
     bool m_parentVisible;
 
index 0e41cc8..7898693 100644 (file)
@@ -48,7 +48,7 @@ public:
     RefPtr<AudioBus> createBus(float sampleRate, bool mixToMono);
 
 private:
-    WeakPtr<AudioFileReader> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<AudioFileReader> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     static void deinterleavePadAddedCallback(AudioFileReader*, GstPad*);
     static void deinterleaveReadyCallback(AudioFileReader*);
@@ -108,15 +108,13 @@ void AudioFileReader::decodebinPadAddedCallback(AudioFileReader* reader, GstPad*
 }
 
 AudioFileReader::AudioFileReader(const char* filePath)
-    : m_weakPtrFactory(this)
-    , m_runLoop(RunLoop::current())
+    : m_runLoop(RunLoop::current())
     , m_filePath(filePath)
 {
 }
 
 AudioFileReader::AudioFileReader(const void* data, size_t dataSize)
-    : m_weakPtrFactory(this)
-    , m_runLoop(RunLoop::current())
+    : m_runLoop(RunLoop::current())
     , m_data(data)
     , m_dataSize(dataSize)
 {
index 0b44f59..dbbdc9f 100644 (file)
@@ -121,12 +121,11 @@ Ref<AudioHardwareListenerMac> AudioHardwareListenerMac::create(Client& client)
 
 AudioHardwareListenerMac::AudioHardwareListenerMac(Client& client)
     : AudioHardwareListener(client)
-    , m_weakFactory(this)
 {
     setHardwareActivity(isAudioHardwareProcessRunning());
     setOutputDeviceSupportsLowPowerMode(currentDeviceSupportsLowPowerBufferSize());
 
-    auto weakThis = m_weakFactory.createWeakPtr();
+    auto weakThis = m_weakFactory.createWeakPtr(*this);
     m_block = Block_copy(^(UInt32 count, const AudioObjectPropertyAddress properties[]) {
         if (weakThis)
             weakThis->propertyChanged(count, properties);
index bea314d..4092177 100644 (file)
@@ -304,7 +304,6 @@ std::optional<String> CDMPrivateClearKey::sanitizeSessionId(const String& sessio
 }
 
 CDMInstanceClearKey::CDMInstanceClearKey()
-    : m_weakPtrFactory(this)
 {
 }
 
@@ -340,7 +339,7 @@ void CDMInstanceClearKey::requestLicense(LicenseType, const AtomicString&, Ref<S
     ++s_sessionIdValue;
 
     callOnMainThread(
-        [weakThis = m_weakPtrFactory.createWeakPtr(), callback = WTFMove(callback), initData = WTFMove(initData), sessionIdValue = s_sessionIdValue]() mutable {
+        [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), initData = WTFMove(initData), sessionIdValue = s_sessionIdValue]() mutable {
             if (!weakThis)
                 return;
 
@@ -355,7 +354,7 @@ void CDMInstanceClearKey::updateLicense(const String& sessionId, LicenseType, co
     auto dispatchCallback =
         [this, &callback](bool sessionWasClosed, std::optional<KeyStatusVector>&& changedKeys, SuccessValue succeeded) {
             callOnMainThread(
-                [weakThis = m_weakPtrFactory.createWeakPtr(), callback = WTFMove(callback), sessionWasClosed, changedKeys = WTFMove(changedKeys), succeeded] () mutable {
+                [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), sessionWasClosed, changedKeys = WTFMove(changedKeys), succeeded] () mutable {
                     if (!weakThis)
                         return;
 
@@ -456,7 +455,7 @@ void CDMInstanceClearKey::updateLicense(const String& sessionId, LicenseType, co
 void CDMInstanceClearKey::loadSession(LicenseType, const String&, const String&, LoadSessionCallback callback)
 {
     callOnMainThread(
-        [weakThis = m_weakPtrFactory.createWeakPtr(), callback = WTFMove(callback)] {
+        [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback)] {
             if (!weakThis)
                 return;
 
@@ -467,7 +466,7 @@ void CDMInstanceClearKey::loadSession(LicenseType, const String&, const String&,
 void CDMInstanceClearKey::closeSession(const String&, CloseSessionCallback callback)
 {
     callOnMainThread(
-        [weakThis = m_weakPtrFactory.createWeakPtr(), callback = WTFMove(callback)] {
+        [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback)] {
             if (!weakThis)
                 return;
 
@@ -478,7 +477,7 @@ void CDMInstanceClearKey::closeSession(const String&, CloseSessionCallback callb
 void CDMInstanceClearKey::removeSessionData(const String&, LicenseType, RemoveSessionDataCallback callback)
 {
     callOnMainThread(
-        [weakThis = m_weakPtrFactory.createWeakPtr(), callback = WTFMove(callback)] {
+        [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback)] {
             if (!weakThis)
                 return;
 
index 91d243e..05f3917 100644 (file)
@@ -78,13 +78,11 @@ FontCascade::CodePath FontCascade::s_codePath = Auto;
 // ============================================================================================
 
 FontCascade::FontCascade()
-    : m_weakPtrFactory(this)
 {
 }
 
 FontCascade::FontCascade(const FontCascadeDescription& fd, float letterSpacing, float wordSpacing)
     : m_fontDescription(fd)
-    , m_weakPtrFactory(this)
     , m_letterSpacing(letterSpacing)
     , m_wordSpacing(wordSpacing)
     , m_useBackslashAsYenSymbol(useBackslashAsYenSignForFamily(fd.firstFamily()))
@@ -96,7 +94,6 @@ FontCascade::FontCascade(const FontCascadeDescription& fd, float letterSpacing,
 // FIXME: We should make this constructor platform-independent.
 FontCascade::FontCascade(const FontPlatformData& fontData, FontSmoothingMode fontSmoothingMode)
     : m_fonts(FontCascadeFonts::createForPlatformFont(fontData))
-    , m_weakPtrFactory(this)
     , m_enableKerning(computeEnableKerning())
     , m_requiresShaping(computeRequiresShaping())
 {
@@ -112,7 +109,6 @@ FontCascade::FontCascade(const FontPlatformData& fontData, FontSmoothingMode fon
 FontCascade::FontCascade(const FontCascade& other)
     : m_fontDescription(other.m_fontDescription)
     , m_fonts(other.m_fonts)
-    , m_weakPtrFactory(this)
     , m_letterSpacing(other.m_letterSpacing)
     , m_wordSpacing(other.m_wordSpacing)
     , m_useBackslashAsYenSymbol(other.m_useBackslashAsYenSymbol)
index a3b1ffe..a446999 100644 (file)
@@ -195,7 +195,7 @@ public:
 
     bool primaryFontIsSystemFont() const;
 
-    WeakPtr<FontCascade> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<FontCascade> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<FontCascade*>(this)); }
 
 private:
     enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
index 1635e99..d429db5 100644 (file)
@@ -55,7 +55,6 @@ namespace WebCore {
 
 MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(MediaPlayer* player)
     : m_player(player)
-    , m_weakPtrFactory(this)
     , m_queuedNotifications()
     , m_queueMutex()
     , m_networkState(MediaPlayer::Empty)
index 37e3be9..5e48525 100644 (file)
@@ -163,7 +163,7 @@ protected:
     explicit MediaPlayerPrivateAVFoundation(MediaPlayer*);
     virtual ~MediaPlayerPrivateAVFoundation();
 
-    WeakPtr<MediaPlayerPrivateAVFoundation> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaPlayerPrivateAVFoundation> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     // MediaPlayerPrivatePrivateInterface overrides.
     void load(const String& url) override;
index bbc05d5..25d0a6e 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     void playerDidReceiveError(NSError *);
 
-    WeakPtr<CDMSessionAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<CDMSessionAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 protected:
     WeakPtr<MediaPlayerPrivateAVFoundationObjC> m_parent;
index 74c3133..bbcd5d3 100644 (file)
@@ -53,7 +53,6 @@ CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFound
     : m_parent(parent->createWeakPtr())
     , m_client(client)
     , m_sessionId(createCanonicalUUIDString())
-    , m_weakPtrFactory(this)
 {
 }
 
index cd828b3..9fa761e 100644 (file)
@@ -89,7 +89,6 @@ namespace WebCore {
 
 CDMSessionAVStreamSession::CDMSessionAVStreamSession(const Vector<int>& protocolVersions, CDMPrivateMediaSourceAVFObjC& cdm, CDMSessionClient* client)
     : CDMSessionMediaSourceAVFObjC(cdm, client)
-    , m_weakPtrFactory(this)
     , m_dataParserObserver(adoptNS([[WebCDMSessionAVStreamSessionObserver alloc] initWithParent:this]))
     , m_protocolVersions(protocolVersions)
     , m_mode(Normal)
index 6255f49..49a71aa 100644 (file)
@@ -158,7 +158,7 @@ public:
     void removeSession(CDMSession&);
 #endif
 
-    WeakPtr<MediaPlayerPrivateAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaPlayerPrivateAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     // engine support
index 6a3eda1..814cfb6 100644 (file)
@@ -541,7 +541,6 @@ void MediaPlayerPrivateAVFoundationObjC::clearMediaCacheForOrigins(const String&
 
 MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
     : MediaPlayerPrivateAVFoundation(player)
-    , m_weakPtrFactory(this)
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     , m_videoFullscreenLayerManager(VideoFullscreenLayerManager::create())
     , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
index 8d38ed1..1b1b971 100644 (file)
@@ -130,7 +130,7 @@ public:
     const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
     bool shouldCheckHardwareSupport() const;
 
-    WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     // MediaPlayerPrivateInterface
index 5c67119..c3b3c7f 100644 (file)
@@ -125,8 +125,6 @@ static void CMTimebaseEffectiveRateChangedCallback(CMNotificationCenterRef, cons
 
 MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer* player)
     : m_player(player)
-    , m_weakPtrFactory(this)
-    , m_sizeChangeObserverWeakPtrFactory(this)
     , m_synchronizer(adoptNS([allocAVSampleBufferRenderSynchronizerInstance() init]))
     , m_seekTimer(*this, &MediaPlayerPrivateMediaSourceAVFObjC::seekInternal)
     , m_session(nullptr)
@@ -890,7 +888,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::effectiveRateChanged()
 
 void MediaPlayerPrivateMediaSourceAVFObjC::sizeWillChangeAtTime(const MediaTime& time, const FloatSize& size)
 {
-    auto weakThis = m_sizeChangeObserverWeakPtrFactory.createWeakPtr();
+    auto weakThis = m_sizeChangeObserverWeakPtrFactory.createWeakPtr(*this);
     NSArray* times = @[[NSValue valueWithCMTime:PAL::toCMTime(time)]];
     RetainPtr<id> observer = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[this, weakThis, size] {
         if (!weakThis)
index e170ff8..c151c72 100644 (file)
@@ -74,7 +74,7 @@ public:
     MediaPlayer::ReadyState readyState() const override;
     void setReadyState(MediaPlayer::ReadyState);
 
-    WeakPtr<MediaPlayerPrivateMediaStreamAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaPlayerPrivateMediaStreamAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     void ensureLayers();
     void destroyLayers();
index 9055dbf..1cd4709 100644 (file)
@@ -188,7 +188,6 @@ static const double rendererLatency = 0.02;
 
 MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC(MediaPlayer* player)
     : m_player(player)
-    , m_weakPtrFactory(this)
     , m_statusChangeListener(adoptNS([[WebAVSampleBufferStatusChangeListener alloc] initWithParent:this]))
     , m_clock(Clock::create())
 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
index f1d16ef..ac9dafb 100644 (file)
@@ -153,7 +153,7 @@ private:
     void flush(AVSampleBufferAudioRenderer *);
 #pragma clang diagnostic pop
 
-    WeakPtr<SourceBufferPrivateAVFObjC> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<SourceBufferPrivateAVFObjC> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
     Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks;
     Vector<RefPtr<AudioTrackPrivateMediaSourceAVFObjC>> m_audioTracks;
index cb6b352..aeb943a 100644 (file)
@@ -479,9 +479,7 @@ RefPtr<SourceBufferPrivateAVFObjC> SourceBufferPrivateAVFObjC::create(MediaSourc
 }
 
 SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
-    : m_weakFactory(this)
-    , m_appendWeakFactory(this)
-    , m_parser(adoptNS([allocAVStreamDataParserInstance() init]))
+    : m_parser(adoptNS([allocAVStreamDataParserInstance() init]))
     , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]))
     , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:this]))
     , m_isAppendingGroup(adoptOSObject(dispatch_group_create()))
@@ -675,7 +673,7 @@ void SourceBufferPrivateAVFObjC::append(const unsigned char* data, unsigned leng
     LOG(MediaSource, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data, length);
 
     RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data length:length]);
-    WeakPtr<SourceBufferPrivateAVFObjC> weakThis = m_appendWeakFactory.createWeakPtr();
+    WeakPtr<SourceBufferPrivateAVFObjC> weakThis = m_appendWeakFactory.createWeakPtr(*this);
     RetainPtr<AVStreamDataParser> parser = m_parser;
     RetainPtr<WebAVStreamDataParserListener> delegate = m_delegate;
 
@@ -715,7 +713,7 @@ void SourceBufferPrivateAVFObjC::abort()
         dispatch_semaphore_signal(m_hasSessionSemaphore.get());
     dispatch_group_wait(m_isAppendingGroup.get(), DISPATCH_TIME_FOREVER);
     m_appendWeakFactory.revokeAll();
-    m_delegate.get().parent = m_appendWeakFactory.createWeakPtr();
+    m_delegate.get().parent = m_appendWeakFactory.createWeakPtr(*this);
 }
 
 void SourceBufferPrivateAVFObjC::resetParserState()
index fe7919c..3da0164 100644 (file)
@@ -50,7 +50,6 @@ std::unique_ptr<TextureCacheCV> TextureCacheCV::create(GraphicsContext3D& contex
 TextureCacheCV::TextureCacheCV(GraphicsContext3D& context, RetainPtr<TextureCacheType>&& cache)
     : m_context(context)
     , m_cache(cache)
-    , m_weakPtrFactory(this)
 {
 }
 
@@ -73,7 +72,7 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVImageB
 #endif
     RetainPtr<TextureType> videoTexture = adoptCF(bareVideoTexture);
 
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
     dispatch_async(dispatch_get_main_queue(), [weakThis] {
         if (!weakThis)
             return;
index 0f2b847..54b95e3 100644 (file)
@@ -140,7 +140,6 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
     , m_seekTime(0)
     , m_source(nullptr)
     , m_volumeAndMuteInitialized(false)
-    , m_weakPtrFactory(this)
     , m_mediaLocations(nullptr)
     , m_mediaLocationCurrentIndex(0)
     , m_playbackRatePause(false)
index 3a30a23..7479487 100644 (file)
@@ -139,7 +139,7 @@ private:
 
     static bool isAvailable();
 
-    WeakPtr<MediaPlayerPrivateGStreamer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaPlayerPrivateGStreamer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     GstElement* createAudioSink() override;
 
index 72aab67..46c8930 100644 (file)
@@ -226,8 +226,7 @@ private:
 #endif // USE(GSTREAMER_GL)
 
 MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
-    : m_weakPtrFactory(this)
-    , m_notifier(MainThreadNotifier<MainThreadNotification>::create())
+    : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
     , m_player(player)
     , m_fpsSink(nullptr)
     , m_readyState(MediaPlayer::HaveNothing)
@@ -364,7 +363,7 @@ bool MediaPlayerPrivateGStreamerBase::handleSyncMessage(GstMessage* message)
         if (concatenatedInitDataChunksNumber > 1)
             eventKeySystemIdString = emptyString();
 
-        RunLoop::main().dispatch([weakThis = m_weakPtrFactory.createWeakPtr(), eventKeySystemIdString, initData = WTFMove(concatenatedInitDataChunks)] {
+        RunLoop::main().dispatch([weakThis = m_weakPtrFactory.createWeakPtr(*this), eventKeySystemIdString, initData = WTFMove(concatenatedInitDataChunks)] {
             if (!weakThis)
                 return;
 
index e31a1a9..5a002c9 100644 (file)
@@ -36,7 +36,6 @@ namespace WebCore {
 
 DisplayRefreshMonitorMac::DisplayRefreshMonitorMac(PlatformDisplayID displayID)
     : DisplayRefreshMonitor(displayID)
-    , m_weakFactory(this)
     , m_displayLink(nullptr)
 {
 }
@@ -92,8 +91,7 @@ void DisplayRefreshMonitorMac::displayLinkFired()
 
     setIsPreviousFrameDone(false);
 
-    // FIXME: Is it really okay to create a weakPtr on a background thread and then use it on the main thread?
-    RunLoop::main().dispatch([weakPtr = m_weakFactory.createWeakPtr()] {
+    RunLoop::main().dispatch([weakPtr = m_weakFactory.createWeakPtr(*this)] {
         if (auto* monitor = weakPtr.get())
             handleDisplayRefreshedNotificationOnMainThread(monitor);
     });
index 2330760..81ff54c 100644 (file)
@@ -97,7 +97,6 @@ MediaPlayerPrivateMediaFoundation::MediaPlayerPrivateMediaFoundation(MediaPlayer
     , m_volume(1.0)
     , m_networkState(MediaPlayer::Empty)
     , m_readyState(MediaPlayer::HaveNothing)
-    , m_weakPtrFactory(this)
 {
     createSession();
     createVideoWindow();
@@ -498,7 +497,7 @@ bool MediaPlayerPrivateMediaFoundation::endCreatedMediaSource(IMFAsyncResult* as
     hr = asyncResult->GetStatus();
     m_loadingProgress = SUCCEEDED(hr);
 
-    callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr()] {
+    callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] {
         if (!weakPtr)
             return;
         weakPtr->onCreatedMediaSource();
@@ -527,7 +526,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult)
 
     switch (mediaEventType) {
     case MESessionTopologySet: {
-        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr()] {
+        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] {
             if (!weakPtr)
                 return;
             weakPtr->onTopologySet();
@@ -536,7 +535,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult)
     }
 
     case MEBufferingStarted: {
-        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr()] {
+        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] {
             if (!weakPtr)
                 return;
             weakPtr->onBufferingStarted();
@@ -545,7 +544,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult)
     }
 
     case MEBufferingStopped: {
-        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr()] {
+        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] {
             if (!weakPtr)
                 return;
             weakPtr->onBufferingStopped();
@@ -554,7 +553,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult)
     }
 
     case MESessionEnded: {
-        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr()] {
+        callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] {
             if (!weakPtr)
                 return;
             weakPtr->onSessionEnded();
@@ -1708,7 +1707,7 @@ HRESULT MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNot
     
     // Invalidate the video area
     if (m_mediaPlayer) {
-        callOnMainThread([weakPtr = m_mediaPlayer->m_weakPtrFactory.createWeakPtr()] {
+        callOnMainThread([weakPtr = m_mediaPlayer->m_weakPtrFactory.createWeakPtr(*m_mediaPlayer)] {
             if (weakPtr)
                 weakPtr->invalidateFrameView();
         });
index fc02ee5..be1594e 100644 (file)
@@ -45,7 +45,7 @@ public:
     virtual ~RemoteCommandListenerIOS();
 
 protected:
-    WeakPtr<RemoteCommandListenerIOS> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RemoteCommandListenerIOS> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
     void updateSupportedCommands() override;
 
     WeakPtrFactory<RemoteCommandListenerIOS> m_weakPtrFactory;
index 41f9db6..e4a69c4 100644 (file)
@@ -47,7 +47,6 @@ std::unique_ptr<RemoteCommandListener> RemoteCommandListener::create(RemoteComma
 
 RemoteCommandListenerIOS::RemoteCommandListenerIOS(RemoteCommandListenerClient& client)
     : RemoteCommandListener(client)
-    , m_weakPtrFactory(this)
 {
     MPRemoteCommandCenter *center = [getMPRemoteCommandCenterClass() sharedCommandCenter];
     auto weakThis = createWeakPtr();
index db69d76..b781e6a 100644 (file)
@@ -39,11 +39,11 @@ public:
     virtual ~RemoteCommandListenerMac();
 
 protected:
-    WeakPtr<RemoteCommandListenerMac> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RemoteCommandListenerMac> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     void updateSupportedCommands() override;
 
-    WeakPtrFactory<RemoteCommandListenerMac> m_weakPtrFactory { this };
+    WeakPtrFactory<RemoteCommandListenerMac> m_weakPtrFactory;
     void* m_commandHandler { nullptr };
 };
     
index b24e64e..7119dbc 100644 (file)
@@ -59,8 +59,7 @@ Ref<MediaStreamPrivate> MediaStreamPrivate::create(const Vector<Ref<RealtimeMedi
 }
 
 MediaStreamPrivate::MediaStreamPrivate(const MediaStreamTrackPrivateVector& tracks, String&& id)
-    : m_weakPtrFactory(this)
-    , m_id(WTFMove(id))
+    : m_id(WTFMove(id))
 {
     ASSERT(!m_id.isEmpty());
 
index 212df90..9f1ab52 100644 (file)
@@ -107,7 +107,7 @@ public:
 
     FloatSize intrinsicSize() const;
 
-    WeakPtr<MediaStreamPrivate> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<MediaStreamPrivate> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     void monitorOrientation(OrientationNotifier&);
 
index 1b75025..6c03762 100644 (file)
@@ -47,8 +47,7 @@
 namespace WebCore {
 
 RealtimeMediaSource::RealtimeMediaSource(const String& id, Type type, const String& name)
-    : m_weakPtrFactory(this)
-    , m_id(id)
+    : m_id(id)
     , m_type(type)
     , m_name(name)
 {
index 1f087f6..846fb72 100644 (file)
@@ -240,7 +240,7 @@ protected:
     void videoSampleAvailable(MediaSample&);
     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t);
 
-    WeakPtr<RealtimeMediaSource> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RealtimeMediaSource> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     virtual void startProducingData() { }
index 375ce7d..0e9b41e 100644 (file)
@@ -57,7 +57,6 @@ MockMediaEndpoint::MockMediaEndpoint(MediaEndpointClient& client)
     , m_iceCandidateTimer(*this, &MockMediaEndpoint::iceCandidateTimerFired)
     , m_iceTransportTimer(*this, &MockMediaEndpoint::iceTransportTimerFired)
     , m_unmuteTimer(*this, &MockMediaEndpoint::unmuteTimerFired)
-    , m_weakPtrFactory(this)
 {
 }
 
@@ -73,7 +72,7 @@ std::unique_ptr<RTCDataChannelHandler> MockMediaEndpoint::createDataChannelHandl
 
 void MockMediaEndpoint::generateDtlsInfo()
 {
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
 
     callOnMainThread([weakThis] {
         if (weakThis)
index ef73d57..8fb0d40 100644 (file)
@@ -47,7 +47,6 @@ RenderMultiColumnSpannerPlaceholder::RenderMultiColumnSpannerPlaceholder(RenderM
     : RenderBox(flowThread->document(), WTFMove(style), RenderBoxModelObjectFlag)
     , m_spanner(&spanner)
     , m_flowThread(flowThread)
-    , m_weakPtrFactory(this)
 {
 }
 
index 03411d9..b150390 100644 (file)
@@ -43,7 +43,7 @@ public:
 
     RenderBox* spanner() const { return m_spanner; }
     RenderMultiColumnFlowThread* flowThread() const { return m_flowThread; }
-    WeakPtr<RenderMultiColumnSpannerPlaceholder> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RenderMultiColumnSpannerPlaceholder> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     RenderMultiColumnSpannerPlaceholder(RenderMultiColumnFlowThread*, RenderBox& spanner, RenderStyle&&);
index 2ab1889..4750608 100644 (file)
@@ -121,7 +121,6 @@ private:
 RenderView::RenderView(Document& document, RenderStyle&& style)
     : RenderBlockFlow(document, WTFMove(style))
     , m_frameView(*document.view())
-    , m_weakFactory(this)
     , m_lazyRepaintTimer(*this, &RenderView::lazyRepaintTimerFired)
 #if ENABLE(SERVICE_CONTROLS)
     , m_selectionRectGatherer(*this)
index aa4f62b..3022307 100644 (file)
@@ -233,7 +233,7 @@ public:
         bool m_wasAccumulatingRepaintRegion;
     };
 
-    WeakPtr<RenderView> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<RenderView> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
     void scheduleLazyRepaint(RenderBox&);
     void unscheduleLazyRepaint(RenderBox&);
index 4ce72ce..4b4d444 100644 (file)
@@ -81,7 +81,6 @@ static void moveWidgetToParentSoon(Widget& child, FrameView* parent)
 
 RenderWidget::RenderWidget(HTMLFrameOwnerElement& element, RenderStyle&& style)
     : RenderReplaced(element, WTFMove(style))
-    , m_weakPtrFactory(this)
 {
     setInline(false);
 }
index b7b7c7b..c12f579 100644 (file)
@@ -71,7 +71,7 @@ public:
 
     bool requiresAcceleratedCompositing() const;
 
-    WeakPtr<RenderWidget> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RenderWidget> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     void ref() { ++m_refCount; }
     void deref();
index 38189a7..6306192 100644 (file)
@@ -61,8 +61,6 @@ RootInlineBox::RootInlineBox(RenderBlockFlow& block)
     : InlineFlowBox(block)
     , m_lineBreakPos(0)
     , m_lineBreakObj(nullptr)
-    , m_weakPtrFactory(this)
-
 {
     setIsHorizontal(block.isHorizontalWritingMode());
 }
index c1958f3..11227c6 100644 (file)
@@ -39,7 +39,7 @@ class RootInlineBox : public InlineFlowBox {
 public:
     explicit RootInlineBox(RenderBlockFlow&);
     virtual ~RootInlineBox();
-    WeakPtr<RootInlineBox> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RootInlineBox> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     RenderBlockFlow& blockFlow() const;
 
index e2230f4..4042317 100644 (file)
@@ -81,7 +81,6 @@ END_REGISTER_ANIMATED_PROPERTIES
 inline SVGPathElement::SVGPathElement(const QualifiedName& tagName, Document& document)
     : SVGGraphicsElement(tagName, document)
     , m_pathSegList(PathSegUnalteredRole)
-    , m_weakPtrFactory(this)
     , m_isAnimValObserved(false)
 {
     ASSERT(hasTagName(SVGNames::pathTag));
index 3f47105..4824782 100644 (file)
@@ -97,7 +97,7 @@ public:
 
     bool isAnimValObserved() const { return m_isAnimValObserved; }
 
-    WeakPtr<SVGPathElement> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<SVGPathElement> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<SVGPathElement*>(this)); }
 
     void animatedPropertyWillBeDeleted();
 
index 0188031..e0bf0d0 100644 (file)
@@ -30,7 +30,7 @@ public:
     {
         ASSERT_UNUSED(value, &parent.propertyReference().svgMatrix() == &value);
         Ref<SVGMatrixTearOff> result = adoptRef(*new SVGMatrixTearOff(parent));
-        parent.addChild(result->m_weakFactory.createWeakPtr());
+        parent.addChild(result->m_weakFactory.createWeakPtr(result));
         return result;
     }
 
@@ -48,7 +48,6 @@ private:
     SVGMatrixTearOff(SVGTransform& parent)
         : SVGMatrix(nullptr)
         , m_parent(&parent)
-        , m_weakFactory(this)
     {
     }
 
index a1a798d..b2fc6c1 100644 (file)
@@ -38,7 +38,6 @@ namespace WebCore {
 
 MockCDMFactory::MockCDMFactory()
     : m_supportedSessionTypes({ MediaKeySessionType::Temporary, MediaKeySessionType::PersistentUsageRecord, MediaKeySessionType::PersistentLicense })
-    , m_weakPtrFactory(this)
 {
     CDMFactory::registerFactory(*this);
 }
@@ -98,12 +97,11 @@ void MockCDMFactory::setSupportedDataTypes(Vector<String>&& types)
 
 std::unique_ptr<CDMPrivate> MockCDMFactory::createCDM(const String&)
 {
-    return std::make_unique<MockCDM>(m_weakPtrFactory.createWeakPtr());
+    return std::make_unique<MockCDM>(m_weakPtrFactory.createWeakPtr(*this));
 }
 
 MockCDM::MockCDM(WeakPtr<MockCDMFactory> factory)
     : m_factory(WTFMove(factory))
-    , m_weakPtrFactory(this)
 {
 }
 
@@ -167,7 +165,7 @@ RefPtr<CDMInstance> MockCDM::createInstance()
 {
     if (m_factory && !m_factory->canCreateInstances())
         return nullptr;
-    return adoptRef(new MockCDMInstance(m_weakPtrFactory.createWeakPtr()));
+    return adoptRef(new MockCDMInstance(m_weakPtrFactory.createWeakPtr(*this)));
 }
 
 void MockCDM::loadAndInitialize()
index 5fb3533..40bf5f4 100644 (file)
@@ -1,3 +1,38 @@
+2017-09-22  Zalan Bujtas  <zalan@apple.com>
+
+        WeakPtrFactory should populate m_ref lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=177375
+
+        Reviewed by Geoffrey Garen.
+
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
+        (WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy):
+        (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard):
+        (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):
+        * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
+        * UIProcess/ApplicationStateTracker.mm:
+        (WebKit::ApplicationStateTracker::ApplicationStateTracker):
+        * UIProcess/Cocoa/WebViewImpl.h:
+        (WebKit::WebViewImpl::createWeakPtr):
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::WebViewImpl):
+        * UIProcess/Launcher/ProcessLauncher.cpp:
+        (WebKit::ProcessLauncher::ProcessLauncher):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        * UIProcess/ProcessAssertion.h:
+        (WebKit::ProcessAssertion::createWeakPtr):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::m_configurationPreferenceValues):
+        (WebKit::m_weakPtrFactory): Deleted.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::createWeakPtr const):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
+        (WebKit::RemoteLayerTreeDrawingArea::createWeakPtr):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
+
 2017-09-22  John Wilander  <wilander@apple.com>
 
         Re-enable configuration.HTTPCookieStorage on session without credentials
index 10e14f7..961bbd3 100644 (file)
@@ -40,7 +40,6 @@ static WebPaymentCoordinatorProxy* activePaymentCoordinatorProxy;
 
 WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy(WebPageProxy& webPageProxy)
     : m_webPageProxy(webPageProxy)
-    , m_weakPtrFactory(this)
     , m_state(State::Idle)
     , m_merchantValidationState(MerchantValidationState::Idle)
 {
@@ -65,7 +64,7 @@ void WebPaymentCoordinatorProxy::canMakePayments(bool& reply)
 
 void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID)
 {
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
     platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, [weakThis, requestID](bool canMakePayments) {
         auto paymentCoordinatorProxy = weakThis.get();
         if (!paymentCoordinatorProxy)
@@ -77,7 +76,7 @@ void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& mer
 
 void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID)
 {
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
     platformOpenPaymentSetup(merchantIdentifier, domainName, [weakThis, requestID](bool result) {
         auto paymentCoordinatorProxy = weakThis.get();
         if (!paymentCoordinatorProxy)
index 3e5069a..a12ec46 100644 (file)
@@ -46,7 +46,7 @@ void WebPaymentCoordinatorProxy::platformShowPaymentUI(const WebCore::URL& origi
     auto paymentRequest = toPKPaymentRequest(m_webPageProxy, originatingURL, linkIconURLStrings, request);
 
     auto showPaymentUIRequestSeed = m_showPaymentUIRequestSeed;
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
     [getPKPaymentAuthorizationViewControllerClass() requestViewControllerWithPaymentRequest:paymentRequest.get() completion:BlockPtr<void (PKPaymentAuthorizationViewController *, NSError *)>::fromCallable([paymentRequest, showPaymentUIRequestSeed, weakThis, completionHandler = WTFMove(completionHandler)](PKPaymentAuthorizationViewController *viewController, NSError *error) {
         auto paymentCoordinatorProxy = weakThis.get();
         if (!paymentCoordinatorProxy)
index 6b2939a..c6523a3 100644 (file)
@@ -79,7 +79,6 @@ ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackg
     , m_didFinishSnapshottingAfterEnteringBackgroundSelector(didFinishSnapshottingAfterEnteringBackgroundSelector)
     , m_willEnterForegroundSelector(willEnterForegroundSelector)
     , m_isInBackground(true)
-    , m_weakPtrFactory(this)
     , m_didEnterBackgroundObserver(nullptr)
     , m_didCreateWindowContextObserver(nullptr)
     , m_didFinishSnapshottingAfterEnteringBackgroundObserver(nullptr)
@@ -94,7 +93,7 @@ ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackg
     ASSERT(window);
 
     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
-    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    auto weakThis = m_weakPtrFactory.createWeakPtr(*this);
     m_didCreateWindowContextObserver = [notificationCenter addObserverForName:@"_UIWindowDidCreateWindowContextNotification" object:window queue:nil usingBlock:[weakThis](NSNotification *) {
         auto applicationStateTracker = weakThis.get();
         if (!applicationStateTracker)
index b4397c6..416dcc0 100644 (file)
@@ -574,7 +574,7 @@ private:
 #endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
 #endif // HAVE(TOUCH_BAR)
 
-    WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     bool supportsArbitraryLayoutModes() const;
     float intrinsicDeviceScaleFactor() const;
index 0155cb1..93846a8 100644 (file)
@@ -1271,7 +1271,6 @@ WebViewImpl::WebViewImpl(NSView <WebViewImplDelegate> *view, WKWebView *outerWeb
     : m_view(view)
     , m_pageClient(std::make_unique<PageClientImpl>(view, outerWebView))
     , m_page(processPool.createWebPage(*m_pageClient, WTFMove(configuration)))
-    , m_weakPtrFactory(this)
     , m_needsViewFrameInWindowCoordinates(m_page->preferences().pluginsEnabled())
     , m_intrinsicContentSize(CGSizeMake(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric))
     , m_layoutStrategy([WKViewLayoutStrategy layoutStrategyWithPage:m_page view:view viewImpl:*this mode:kWKLayoutModeViewSize])
index f2f72ac..0ffa92d 100644 (file)
@@ -33,7 +33,6 @@ namespace WebKit {
 
 ProcessLauncher::ProcessLauncher(Client* client, const LaunchOptions& launchOptions)
     : m_client(client)
-    , m_weakPtrFactory(this)
     , m_launchOptions(launchOptions)
     , m_processIdentifier(0)
 {
index a1660b4..6489f5b 100644 (file)
@@ -186,7 +186,7 @@ void ProcessLauncher::launchProcess()
 
     xpc_dictionary_set_value(bootstrapMessage.get(), "extra-initialization-data", extraInitializationData.get());
 
-    auto weakProcessLauncher = m_weakPtrFactory.createWeakPtr();
+    auto weakProcessLauncher = m_weakPtrFactory.createWeakPtr(*this);
     xpc_connection_set_event_handler(m_xpcConnection.get(), [weakProcessLauncher, listeningPort](xpc_object_t event) {
         ASSERT(xpc_get_type(event) == XPC_TYPE_ERROR);
 
index 2032000..4d4dc66 100644 (file)
@@ -69,7 +69,7 @@ protected:
 
 private:
 #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
-    WeakPtr<ProcessAssertion> createWeakPtr() { return m_weakFactory.createWeakPtr(); }
+    WeakPtr<ProcessAssertion> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
     void markAsInvalidated();
 
     RetainPtr<BKSProcessAssertion> m_assertion;
index 1265781..f3b52fe 100644 (file)
@@ -365,7 +365,6 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
 #endif
     , m_pageLoadState(*this)
     , m_configurationPreferenceValues(m_configuration->preferenceValues())
-    , m_weakPtrFactory(this)
 {
     m_webProcessLifetimeTracker.addObserver(m_visitedLinkStore);
     m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
index b564cdc..7152822 100644 (file)
@@ -1190,7 +1190,7 @@ public:
     void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible);
 #endif
         
-    WeakPtr<WebPageProxy> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<WebPageProxy> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<WebPageProxy*>(this)); }
 
     void isLoadingChanged() { activityStateDidChange(WebCore::ActivityState::IsLoading); }
 
index 4c34e90..b6ab864 100644 (file)
@@ -97,7 +97,6 @@ WaylandCompositor::Buffer* WaylandCompositor::Buffer::getOrCreate(struct wl_reso
 
 WaylandCompositor::Buffer::Buffer(struct wl_resource* resource)
     : m_resource(resource)
-    , m_weakPtrFactory(this)
 {
     wl_list_init(&m_destroyListener.link);
     m_destroyListener.notify = destroyListenerCallback;
index 9bbeb7a..e5aba03 100644 (file)
@@ -65,7 +65,7 @@ public:
         EGLImageKHR createImage() const;
         WebCore::IntSize size() const;
 
-        WeakPtr<Buffer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+        WeakPtr<Buffer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
     private:
         Buffer(struct wl_resource*);
index b529607..810c6f3 100644 (file)
@@ -161,8 +161,7 @@ static BKSProcessAssertionFlags flagsForState(AssertionState assertionState)
 }
 
 ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState, Function<void()>&& invalidationCallback)
-    : m_weakFactory(this)
-    , m_invalidationCallback(WTFMove(invalidationCallback))
+    : m_invalidationCallback(WTFMove(invalidationCallback))
     , m_assertionState(assertionState)
 {
     auto weakThis = createWeakPtr();
index 4275ae3..e58dd61 100644 (file)
@@ -54,7 +54,7 @@ public:
     uint64_t nextTransactionID() const { return m_currentTransactionID + 1; }
     uint64_t lastCommittedTransactionID() const { return m_currentTransactionID; }
 
-    WeakPtr<RemoteLayerTreeDrawingArea> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
+    WeakPtr<RemoteLayerTreeDrawingArea> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 
 private:
     // DrawingArea
index e0fe4c1..9eba9a9 100644 (file)
@@ -60,7 +60,6 @@ RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea(WebPage& webPage, const W
     , m_remoteLayerTreeContext(std::make_unique<RemoteLayerTreeContext>(webPage))
     , m_rootLayer(GraphicsLayer::create(graphicsLayerFactory(), *this))
     , m_layerFlushTimer(*this, &RemoteLayerTreeDrawingArea::flushLayers)
-    , m_weakPtrFactory(this)
 {
     webPage.corePage()->settings().setForceCompositingMode(true);
 #if PLATFORM(IOS)
index 10fc166..7f27ce0 100644 (file)
@@ -1,3 +1,14 @@
+2017-09-22  Zalan Bujtas  <zalan@apple.com>
+
+        WeakPtrFactory should populate m_ref lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=177375
+
+        Reviewed by Geoffrey Garen.
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::WebEditorClient):
+        (WebEditorClient::requestCandidatesForSelection):
+
 2017-09-22  Chris Dumez  <cdumez@apple.com>
 
         Use high resolution timestamp for event time
index 3ddebb5..343c2c7 100644 (file)
@@ -195,7 +195,6 @@ static WebViewInsertAction kit(EditorInsertAction action)
 WebEditorClient::WebEditorClient(WebView *webView)
     : m_webView(webView)
     , m_undoTarget(adoptNS([[WebEditorUndoTarget alloc] init]))
-    , m_weakPtrFactory(this)
 {
 }
 
@@ -1247,7 +1246,7 @@ void WebEditorClient::requestCandidatesForSelection(const VisibleSelection& sele
     m_paragraphContextForCandidateRequest = plainText(frame->editor().contextRangeForCandidateRequest().get());
 
     NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection;
-    auto weakEditor = m_weakPtrFactory.createWeakPtr();
+    auto weakEditor = m_weakPtrFactory.createWeakPtr(*this);
     m_lastCandidateRequestSequenceNumber = [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:m_rangeForCandidates inString:m_paragraphContextForCandidateRequest.get() types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakEditor](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) {
         dispatch_async(dispatch_get_main_queue(), ^{
             if (!weakEditor)
index 8c28c84..59b4b16 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-22  Zalan Bujtas  <zalan@apple.com>
+
+        WeakPtrFactory should populate m_ref lazily.
+        https://bugs.webkit.org/show_bug.cgi?id=177375
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
+        (TestWebKitAPI::TEST):
+
 2017-09-22  Filip Pizlo  <fpizlo@apple.com>
 
         WSL should report an error if you try to create an operator overload that will never be called
index 745aadd..9c5ac59 100644 (file)
@@ -33,10 +33,10 @@ namespace TestWebKitAPI {
 TEST(WTF_WeakPtr, Basic)
 {
     int dummy = 5;
-    WeakPtrFactory<int>* factory = new WeakPtrFactory<int>(&dummy);
-    WeakPtr<int> weakPtr1 = factory->createWeakPtr();
-    WeakPtr<int> weakPtr2 = factory->createWeakPtr();
-    WeakPtr<int> weakPtr3 = factory->createWeakPtr();
+    WeakPtrFactory<int>* factory = new WeakPtrFactory<int>();
+    WeakPtr<int> weakPtr1 = factory->createWeakPtr(dummy);
+    WeakPtr<int> weakPtr2 = factory->createWeakPtr(dummy);
+    WeakPtr<int> weakPtr3 = factory->createWeakPtr(dummy);
     EXPECT_EQ(weakPtr1.get(), &dummy);
     EXPECT_EQ(weakPtr2.get(), &dummy);
     EXPECT_EQ(weakPtr3.get(), &dummy);
@@ -60,9 +60,9 @@ TEST(WTF_WeakPtr, Assignment)
     int dummy = 5;
     WeakPtr<int> weakPtr;
     {
-        WeakPtrFactory<int> factory(&dummy);
+        WeakPtrFactory<int> factory;
         EXPECT_NULL(weakPtr.get());
-        weakPtr = factory.createWeakPtr();
+        weakPtr = factory.createWeakPtr(dummy);
         EXPECT_EQ(weakPtr.get(), &dummy);
     }
     EXPECT_NULL(weakPtr.get());
@@ -72,10 +72,10 @@ TEST(WTF_WeakPtr, MultipleFactories)
 {
     int dummy1 = 5;
     int dummy2 = 7;
-    WeakPtrFactory<int>* factory1 = new WeakPtrFactory<int>(&dummy1);
-    WeakPtrFactory<int>* factory2 = new WeakPtrFactory<int>(&dummy2);
-    WeakPtr<int> weakPtr1 = factory1->createWeakPtr();
-    WeakPtr<int> weakPtr2 = factory2->createWeakPtr();
+    WeakPtrFactory<int>* factory1 = new WeakPtrFactory<int>();
+    WeakPtrFactory<int>* factory2 = new WeakPtrFactory<int>();
+    WeakPtr<int> weakPtr1 = factory1->createWeakPtr(dummy1);
+    WeakPtr<int> weakPtr2 = factory2->createWeakPtr(dummy2);
     EXPECT_EQ(weakPtr1.get(), &dummy1);
     EXPECT_EQ(weakPtr2.get(), &dummy2);
     EXPECT_TRUE(weakPtr1 != weakPtr2);
@@ -91,10 +91,10 @@ TEST(WTF_WeakPtr, MultipleFactories)
 TEST(WTF_WeakPtr, RevokeAll)
 {
     int dummy = 5;
-    WeakPtrFactory<int> factory(&dummy);
-    WeakPtr<int> weakPtr1 = factory.createWeakPtr();
-    WeakPtr<int> weakPtr2 = factory.createWeakPtr();
-    WeakPtr<int> weakPtr3 = factory.createWeakPtr();
+    WeakPtrFactory<int> factory;
+    WeakPtr<int> weakPtr1 = factory.createWeakPtr(dummy);
+    WeakPtr<int> weakPtr2 = factory.createWeakPtr(dummy);
+    WeakPtr<int> weakPtr3 = factory.createWeakPtr(dummy);
     EXPECT_EQ(weakPtr1.get(), &dummy);
     EXPECT_EQ(weakPtr2.get(), &dummy);
     EXPECT_EQ(weakPtr3.get(), &dummy);
@@ -104,15 +104,6 @@ TEST(WTF_WeakPtr, RevokeAll)
     EXPECT_NULL(weakPtr3.get());
 }
 
-TEST(WTF_WeakPtr, NullFactory)
-{
-    WeakPtrFactory<int> factory(nullptr);
-    WeakPtr<int> weakPtr = factory.createWeakPtr();
-    EXPECT_NULL(weakPtr.get());
-    factory.revokeAll();
-    EXPECT_NULL(weakPtr.get());
-}
-
 struct Foo {
     void bar() { };
 };
@@ -120,8 +111,8 @@ struct Foo {
 TEST(WTF_WeakPtr, Dereference)
 {
     Foo f;
-    WeakPtrFactory<Foo> factory(&f);
-    WeakPtr<Foo> weakPtr = factory.createWeakPtr();
+    WeakPtrFactory<Foo> factory;
+    WeakPtr<Foo> weakPtr = factory.createWeakPtr(f);
     weakPtr->bar();
 }
 
@@ -130,13 +121,13 @@ TEST(WTF_WeakPtr, Forget)
     int dummy = 5;
     int dummy2 = 7;
 
-    WeakPtrFactory<int> outerFactory(&dummy2);
+    WeakPtrFactory<int> outerFactory;
     WeakPtr<int> weakPtr1, weakPtr2, weakPtr3, weakPtr4;
     {
-        WeakPtrFactory<int> innerFactory(&dummy);
-        weakPtr1 = innerFactory.createWeakPtr();
-        weakPtr2 = innerFactory.createWeakPtr();
-        weakPtr3 = innerFactory.createWeakPtr();
+        WeakPtrFactory<int> innerFactory;
+        weakPtr1 = innerFactory.createWeakPtr(dummy);
+        weakPtr2 = innerFactory.createWeakPtr(dummy);
+        weakPtr3 = innerFactory.createWeakPtr(dummy);
         EXPECT_EQ(weakPtr1.get(), &dummy);
         EXPECT_EQ(weakPtr2.get(), &dummy);
         EXPECT_EQ(weakPtr3.get(), &dummy);
@@ -166,7 +157,7 @@ TEST(WTF_WeakPtr, Forget)
         EXPECT_NULL(weakPtr5.get());
         EXPECT_EQ(weakPtr2.get(), &dummy);
 
-        weakPtr4 = outerFactory.createWeakPtr();
+        weakPtr4 = outerFactory.createWeakPtr(dummy2);
         EXPECT_EQ(weakPtr2.get(), &dummy);
         EXPECT_EQ(weakPtr4.get(), &dummy2);
     }
@@ -184,7 +175,7 @@ TEST(WTF_WeakPtr, Forget)
     EXPECT_NULL(weakPtr6.get());
     EXPECT_EQ(weakPtr5.get(), weakPtr6.get());
 
-    WeakPtr<int> weakPtr7 = outerFactory.createWeakPtr();
+    WeakPtr<int> weakPtr7 = outerFactory.createWeakPtr(dummy2);
     EXPECT_EQ(weakPtr7.get(), &dummy2);
     weakPtr7 = nullptr;
     EXPECT_NULL(weakPtr7.get());