WebKit Bugzilla
Attachment 342216 Details for
Bug 186407
: Add base class to get WeakPtrFactory member and avoid some boilerplate code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186407-20180607161320.patch (text/plain), 210.08 KB, created by
Chris Dumez
on 2018-06-07 16:13:21 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-06-07 16:13:21 PDT
Size:
210.08 KB
patch
obsolete
>Subversion Revision: 232581 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index eb38071d1e85df49246c1bac80bafa152f8b2daf..9cd94e7ed56fcafd7719dc4ba5ae00f7648e7d42 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,19 @@ >+2018-06-07 Chris Dumez <cdumez@apple.com> >+ >+ Add base class to get WeakPtrFactory member and avoid some boilerplate code >+ https://bugs.webkit.org/show_bug.cgi?id=186407 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add CanMakeWeakPtr base class to get WeakPtrFactory member and its getter, in >+ order to avoid some boilerplate code in every class needing a WeakPtrFactory. >+ This also gets rid of old-style createWeakPtr() methods in favor of the newer >+ makeWeakPtr(). >+ >+ * wasm/WasmInstance.h: >+ * wasm/WasmMemory.cpp: >+ (JSC::Wasm::Memory::registerInstance): >+ > 2018-06-07 Saam Barati <sbarati@apple.com> > > Make DFG to FTL OSR entry code more sane by removing bad RELEASE_ASSERTS and making it trigger compiles in outer loops before inner ones >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 05db42447c58fa0bf37e7a8e514eaff731767a85..903ea8412d754eeaec1c0268f0466b5851a59e47 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,19 @@ >+2018-06-07 Chris Dumez <cdumez@apple.com> >+ >+ Add base class to get WeakPtrFactory member and avoid some boilerplate code >+ https://bugs.webkit.org/show_bug.cgi?id=186407 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add CanMakeWeakPtr base class to get WeakPtrFactory member and its getter, in >+ order to avoid some boilerplate code in every class needing a WeakPtrFactory. >+ This also gets rid of old-style createWeakPtr() methods in favor of the newer >+ makeWeakPtr(). >+ >+ * wtf/WeakPtr.h: >+ (WTF::CanMakeWeakPtr::weakPtrFactory const): >+ (WTF::CanMakeWeakPtr::weakPtrFactory): >+ > 2018-06-05 Darin Adler <darin@apple.com> > > [Cocoa] Retire DispatchPtr, and add more move semantics and simpler #ifs to other smart pointers >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 824dd7c68f90b3c1c1aedc51828116256727cb2d..936ea1c924d2b6f03accf48d6fc342706ff09e1b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,235 @@ >+2018-06-07 Chris Dumez <cdumez@apple.com> >+ >+ Add base class to get WeakPtrFactory member and avoid some boilerplate code >+ https://bugs.webkit.org/show_bug.cgi?id=186407 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add CanMakeWeakPtr base class to get WeakPtrFactory member and its getter, in >+ order to avoid some boilerplate code in every class needing a WeakPtrFactory. >+ This also gets rid of old-style createWeakPtr() methods in favor of the newer >+ makeWeakPtr(). >+ >+ * Modules/credentialmanagement/CredentialsMessenger.h: >+ * Modules/credentialmanagement/NavigatorCredentials.cpp: >+ (WebCore::NavigatorCredentials::credentials): >+ * Modules/encryptedmedia/CDM.cpp: >+ (WebCore::CDM::doSupportedConfigurationStep): >+ (WebCore::CDM::getConsentStatus): >+ * Modules/encryptedmedia/CDM.h: >+ * Modules/encryptedmedia/MediaKeySession.cpp: >+ (WebCore::MediaKeySession::generateRequest): >+ (WebCore::MediaKeySession::load): >+ (WebCore::MediaKeySession::update): >+ (WebCore::MediaKeySession::close): >+ (WebCore::MediaKeySession::remove): >+ * Modules/encryptedmedia/MediaKeySession.h: >+ * Modules/encryptedmedia/MediaKeys.cpp: >+ (WebCore::MediaKeys::createSession): >+ * Modules/encryptedmedia/MediaKeys.h: >+ * Modules/gamepad/GamepadManager.cpp: >+ (WebCore::GamepadManager::platformGamepadDisconnected): >+ (WebCore::GamepadManager::makeGamepadVisible): >+ * Modules/mediastream/MediaDevices.cpp: >+ (WebCore::MediaDevices::MediaDevices): >+ * Modules/mediastream/MediaDevices.h: >+ * Modules/mediastream/MediaStreamTrack.cpp: >+ (WebCore::MediaStreamTrack::applyConstraints): >+ * Modules/mediastream/MediaStreamTrack.h: >+ * Modules/webauthn/cocoa/LocalAuthenticator.h: >+ * Modules/webauthn/cocoa/LocalAuthenticator.mm: >+ (WebCore::LocalAuthenticator::makeCredential): >+ * accessibility/AccessibilityRenderObject.h: >+ * accessibility/AccessibilitySVGRoot.cpp: >+ (WebCore::AccessibilitySVGRoot::setParent): >+ * crypto/SubtleCrypto.cpp: >+ (WebCore::SubtleCrypto::encrypt): >+ (WebCore::SubtleCrypto::decrypt): >+ (WebCore::SubtleCrypto::sign): >+ (WebCore::SubtleCrypto::verify): >+ (WebCore::SubtleCrypto::digest): >+ (WebCore::SubtleCrypto::generateKey): >+ (WebCore::SubtleCrypto::deriveKey): >+ (WebCore::SubtleCrypto::deriveBits): >+ (WebCore::SubtleCrypto::importKey): >+ (WebCore::SubtleCrypto::exportKey): >+ (WebCore::SubtleCrypto::wrapKey): >+ (WebCore::SubtleCrypto::unwrapKey): >+ * crypto/SubtleCrypto.h: >+ * css/CSSFontFace.cpp: >+ (WebCore::CSSFontFace::CSSFontFace): >+ (WebCore::CSSFontFace::wrapper): >+ (WebCore::CSSFontFace::setWrapper): >+ * css/DeprecatedCSSOMValue.h: >+ * css/FontFace.cpp: >+ * css/FontFace.h: >+ * css/MediaQueryEvaluator.cpp: >+ (WebCore::MediaQueryEvaluator::MediaQueryEvaluator): >+ * css/StyleSheetContents.h: >+ * css/parser/CSSDeferredParser.cpp: >+ (WebCore::CSSDeferredParser::CSSDeferredParser): >+ * dom/DataTransferItemList.cpp: >+ (WebCore::DataTransferItemList::add): >+ (WebCore::DataTransferItemList::ensureItems const): >+ (WebCore::DataTransferItemList::didSetStringData): >+ * dom/DataTransferItemList.h: >+ * dom/Document.cpp: >+ (WebCore::Document::postTask): >+ (WebCore::Document::hasStorageAccess): >+ (WebCore::Document::requestStorageAccess): >+ * dom/Document.h: >+ (WebCore::Document::setContextDocument): >+ * dom/MessagePort.h: >+ * html/HTMLImageElement.cpp: >+ (WebCore::HTMLImageElement::setPictureElement): >+ * html/HTMLInputElement.h: >+ * html/HTMLMediaElement.cpp: >+ (WebCore::HTMLMediaElement::mediaPlayerCreateResourceLoader): >+ * html/HTMLMediaElement.h: >+ * html/HTMLPictureElement.h: >+ * html/parser/HTMLResourcePreloader.h: >+ * layout/layouttree/LayoutBox.h: >+ (WebCore::Layout::Box::style const): >+ * loader/FormState.h: >+ * loader/LinkLoader.cpp: >+ (WebCore::LinkLoader::preconnectIfNeeded): >+ * loader/LinkLoader.h: >+ * loader/LinkPreloadResourceClients.cpp: >+ (WebCore::LinkPreloadResourceClient::LinkPreloadResourceClient): >+ * loader/MediaResourceLoader.cpp: >+ (WebCore::MediaResourceLoader::MediaResourceLoader): >+ * loader/MediaResourceLoader.h: >+ * page/DOMWindow.h: >+ * page/EventHandler.cpp: >+ (WebCore::widgetForElement): >+ (WebCore::EventHandler::updateLastScrollbarUnderMouse): >+ * platform/GenericTaskQueue.cpp: >+ (WebCore::TaskDispatcher<Timer>::postTask): >+ * platform/GenericTaskQueue.h: >+ (WebCore::GenericTaskQueue::enqueueTask): >+ (WebCore::GenericTaskQueue::cancelAllTasks): >+ * platform/ScrollView.h: >+ * platform/ScrollableArea.h: >+ * platform/Scrollbar.h: >+ * platform/Widget.cpp: >+ (WebCore::Widget::setParent): >+ * platform/Widget.h: >+ * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp: >+ (WebCore::AudioFileReader::decodeAudioForBusCreation): >+ * platform/audio/mac/AudioHardwareListenerMac.cpp: >+ (WebCore::AudioHardwareListenerMac::AudioHardwareListenerMac): >+ * platform/audio/mac/AudioHardwareListenerMac.h: >+ * platform/encryptedmedia/clearkey/CDMClearKey.cpp: >+ (WebCore::CDMInstanceClearKey::requestLicense): >+ (WebCore::CDMInstanceClearKey::updateLicense): >+ (WebCore::CDMInstanceClearKey::loadSession): >+ (WebCore::CDMInstanceClearKey::closeSession): >+ (WebCore::CDMInstanceClearKey::removeSessionData): >+ * platform/encryptedmedia/clearkey/CDMClearKey.h: >+ * platform/graphics/FontCascade.h: >+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: >+ (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): >+ (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): >+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: >+ * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h: >+ * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: >+ (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest): >+ * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h: >+ * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: >+ (WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC): >+ * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::checkPlayability): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::beginLoadingMetadata): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::seekToTime): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createSession): >+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): >+ (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: >+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: >+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::requestNotificationWhenReadyForVideoData): >+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): >+ * platform/graphics/cv/TextureCacheCV.h: >+ * platform/graphics/cv/TextureCacheCV.mm: >+ (WebCore::TextureCacheCV::textureFromImage): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: >+ (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo): >+ (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio): >+ (WebCore::MediaPlayerPrivateGStreamer::handleMessage): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: >+ (WebCore::MediaPlayerPrivateGStreamerBase::handleSyncMessage): >+ (WebCore::MediaPlayerPrivateGStreamerBase::initializationDataEncountered): >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: >+ * platform/graphics/gstreamer/mse/AppendPipeline.cpp: >+ (WebCore::AppendPipeline::connectDemuxerSrcPadToAppsink): >+ * platform/graphics/mac/DisplayRefreshMonitorMac.cpp: >+ (WebCore::DisplayRefreshMonitorMac::displayLinkFired): >+ * platform/graphics/mac/DisplayRefreshMonitorMac.h: >+ * platform/graphics/texmap/TextureMapperLayer.cpp: >+ (WebCore::TextureMapperLayer::setMaskLayer): >+ (WebCore::TextureMapperLayer::setReplicaLayer): >+ * platform/graphics/texmap/TextureMapperLayer.h: >+ * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: >+ (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): >+ (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): >+ (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): >+ * platform/graphics/win/MediaPlayerPrivateMediaFoundation.h: >+ * platform/ios/RemoteCommandListenerIOS.h: >+ * platform/ios/RemoteCommandListenerIOS.mm: >+ (WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS): >+ * platform/mac/RemoteCommandListenerMac.h: >+ * platform/mac/RemoteCommandListenerMac.mm: >+ (WebCore::RemoteCommandListenerMac::RemoteCommandListenerMac): >+ * platform/mediastream/MediaStreamPrivate.cpp: >+ (WebCore::MediaStreamPrivate::scheduleDeferredTask): >+ * platform/mediastream/MediaStreamPrivate.h: >+ * platform/mediastream/RealtimeMediaSource.cpp: >+ (WebCore::RealtimeMediaSource::scheduleDeferredTask): >+ * platform/mediastream/RealtimeMediaSource.h: >+ * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h: >+ * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm: >+ (WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream): >+ * platform/vr/VRPlatformDisplay.h: >+ * platform/vr/openvr/VRPlatformManagerOpenVR.cpp: >+ (WebCore::VRPlatformManagerOpenVR::getVRDisplays): >+ * rendering/FloatingObjects.h: >+ (WebCore::FloatingObject::setOriginatingLine): >+ * rendering/RenderObject.h: >+ * rendering/RootInlineBox.cpp: >+ * rendering/RootInlineBox.h: >+ * svg/SVGPathElement.h: >+ * svg/SVGPathSegWithContext.h: >+ (WebCore::SVGPathSegWithContext::SVGPathSegWithContext): >+ (WebCore::SVGPathSegWithContext::setContextAndRole): >+ * svg/SVGTransformList.h: >+ * svg/properties/SVGAnimatedListPropertyTearOff.h: >+ (WebCore::SVGAnimatedListPropertyTearOff::baseVal): >+ (WebCore::SVGAnimatedListPropertyTearOff::animVal): >+ * svg/properties/SVGAnimatedPathSegListPropertyTearOff.h: >+ * svg/properties/SVGAnimatedPropertyTearOff.h: >+ * svg/properties/SVGAnimatedTransformListPropertyTearOff.h: >+ * svg/properties/SVGListProperty.h: >+ (WebCore::SVGListProperty::initializeValuesAndWrappers): >+ (WebCore::SVGListProperty::getItemValuesAndWrappers): >+ (WebCore::SVGListProperty::insertItemBeforeValuesAndWrappers): >+ (WebCore::SVGListProperty::replaceItemValuesAndWrappers): >+ (WebCore::SVGListProperty::appendItemValuesAndWrappers): >+ * svg/properties/SVGMatrixTearOff.h: >+ * svg/properties/SVGPropertyTearOff.h: >+ * testing/MockCDMFactory.cpp: >+ (WebCore::MockCDMFactory::createCDM): >+ (WebCore::MockCDM::createInstance): >+ * testing/MockCDMFactory.h: >+ * workers/service/ExtendableEvent.h: >+ * workers/service/FetchEvent.cpp: >+ (WebCore::FetchEvent::respondWith): >+ * workers/service/server/SWServer.h: >+ * xml/DOMParser.cpp: >+ (WebCore::DOMParser::DOMParser): >+ > 2018-06-07 Zalan Bujtas <zalan@apple.com> > > [LFC] Merge height and vertical margin computation >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index 0b887c06146608357c17e814aa31c7186e795c43..95d9dc10a2051ef4385d10ee3af2d5aace9592e4 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,16 @@ >+2018-06-07 Chris Dumez <cdumez@apple.com> >+ >+ Add base class to get WeakPtrFactory member and avoid some boilerplate code >+ https://bugs.webkit.org/show_bug.cgi?id=186407 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 186407_CanMakeWeakPtr >+ >+ * pal/system/mac/SystemSleepListenerMac.h: >+ * pal/system/mac/SystemSleepListenerMac.mm: >+ (PAL::SystemSleepListenerMac::SystemSleepListenerMac): >+ > 2018-06-06 Simon Fraser <simon.fraser@apple.com> > > Logging macros are sensitive to pal/Logging.h vs Logging.h include order >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 409d36a6f9ab9c9a0d76140d98d51e3876921738..092e3ae0ae18f974677a971228839143be8ac06c 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,70 @@ >+2018-06-07 Chris Dumez <cdumez@apple.com> >+ >+ Add base class to get WeakPtrFactory member and avoid some boilerplate code >+ https://bugs.webkit.org/show_bug.cgi?id=186407 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add CanMakeWeakPtr base class to get WeakPtrFactory member and its getter, in >+ order to avoid some boilerplate code in every class needing a WeakPtrFactory. >+ This also gets rid of old-style createWeakPtr() methods in favor of the newer >+ makeWeakPtr(). >+ >+ * NetworkProcess/NetworkLoadChecker.h: >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::canAuthenticateAgainstProtectionSpace): >+ * NetworkProcess/PreconnectTask.h: >+ * NetworkProcess/cache/CacheStorageEngine.h: >+ * Shared/Authentication/AuthenticationManager.h: >+ * UIProcess/API/APIAttachment.cpp: >+ (API::Attachment::Attachment): >+ * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp: >+ (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard): >+ (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup): >+ * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h: >+ * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm: >+ (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): >+ * UIProcess/ApplicationStateTracker.h: >+ * UIProcess/ApplicationStateTracker.mm: >+ (WebKit::ApplicationStateTracker::ApplicationStateTracker): >+ * UIProcess/Cocoa/ViewGestureController.cpp: >+ (WebKit::ViewGestureController::setAlternateBackForwardListSourcePage): >+ * UIProcess/Cocoa/WebViewImpl.h: >+ * UIProcess/Cocoa/WebViewImpl.mm: >+ (WebKit::WebViewImpl::updateWindowAndViewFrames): >+ (WebKit::WebViewImpl::setTopContentInset): >+ (WebKit::WebViewImpl::viewDidMoveToWindow): >+ (WebKit::WebViewImpl::prepareForMoveToWindow): >+ (WebKit::WebViewImpl::validateUserInterfaceItem): >+ (WebKit::WebViewImpl::requestCandidatesForSelectionIfNeeded): >+ (WebKit::WebViewImpl::interpretKeyEvent): >+ (WebKit::WebViewImpl::firstRectForCharacterRange): >+ (WebKit::WebViewImpl::performKeyEquivalent): >+ (WebKit::WebViewImpl::keyUp): >+ (WebKit::WebViewImpl::keyDown): >+ * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp: >+ (WebKit::WebCredentialsMessengerProxy::makeCredential): >+ (WebKit::WebCredentialsMessengerProxy::getAssertion): >+ * UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h: >+ * UIProcess/Downloads/DownloadProxy.cpp: >+ (WebKit::DownloadProxy::setOriginatingPage): >+ * UIProcess/Launcher/ProcessLauncher.h: >+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm: >+ (WebKit::ProcessLauncher::launchProcess): >+ * UIProcess/ProcessAssertion.h: >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebsiteData/WebsiteDataStore.h: >+ * UIProcess/gtk/WaylandCompositor.cpp: >+ (WebKit::WaylandCompositor::Surface::attachBuffer): >+ * UIProcess/gtk/WaylandCompositor.h: >+ * UIProcess/ios/ProcessAssertionIOS.mm: >+ (WebKit::ProcessAssertion::ProcessAssertion): >+ * UIProcess/mac/DisplayLink.cpp: >+ (WebKit::DisplayLink::displayLinkCallback): >+ * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm: >+ (WebKit::RemoteLayerTreeDisplayRefreshMonitor::RemoteLayerTreeDisplayRefreshMonitor): >+ * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h: >+ > 2018-06-07 Dan Bernstein <mitz@apple.com> > > REGRESSION (r232520): Crash under IPC::ArgumentCoder<WebCore::Credential>::encodePlatformData >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index f8e309a183955ea73d8c3383f92e1eb879d63327..07c51d9b720ea98dbb7e6d0a59b99f2293468ab2 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,19 @@ >+2018-06-07 Chris Dumez <cdumez@apple.com> >+ >+ Add base class to get WeakPtrFactory member and avoid some boilerplate code >+ https://bugs.webkit.org/show_bug.cgi?id=186407 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add CanMakeWeakPtr base class to get WeakPtrFactory member and its getter, in >+ order to avoid some boilerplate code in every class needing a WeakPtrFactory. >+ This also gets rid of old-style createWeakPtr() methods in favor of the newer >+ makeWeakPtr(). >+ >+ * WebCoreSupport/WebEditorClient.h: >+ * WebCoreSupport/WebEditorClient.mm: >+ (WebEditorClient::requestCandidatesForSelection): >+ > 2018-06-05 Chris Dumez <cdumez@apple.com> > > Regression(r232082): Websites get loaded inside of Messages App chat transcript >diff --git a/Source/JavaScriptCore/wasm/WasmInstance.h b/Source/JavaScriptCore/wasm/WasmInstance.h >index c70c498d978be633eec8d27e85ebaaf4a01b6b51..a7738780edb4b2402bb69984fb8f391dc7f8aa97 100644 >--- a/Source/JavaScriptCore/wasm/WasmInstance.h >+++ b/Source/JavaScriptCore/wasm/WasmInstance.h >@@ -40,7 +40,7 @@ namespace JSC { namespace Wasm { > > struct Context; > >-class Instance : public ThreadSafeRefCounted<Instance> { >+class Instance : public ThreadSafeRefCounted<Instance>, public CanMakeWeakPtr<Instance> { > public: > using StoreTopCallFrameCallback = WTF::Function<void(void*)>; > >@@ -69,7 +69,6 @@ public: > void* cachedMemory() const { return m_cachedMemory; } > size_t cachedMemorySize() const { return m_cachedMemorySize; } > >- WeakPtr<Instance> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > void setMemory(Ref<Memory>&& memory) > { > m_memory = WTFMove(memory); >@@ -157,7 +156,6 @@ private: > void** m_pointerToActualStackLimit { nullptr }; > void* m_cachedStackLimit { bitwise_cast<void*>(std::numeric_limits<uintptr_t>::max()) }; > StoreTopCallFrameCallback m_storeTopCallFrame; >- WeakPtrFactory<Instance> m_weakPtrFactory; > unsigned m_numImportFunctions { 0 }; > }; > >diff --git a/Source/JavaScriptCore/wasm/WasmMemory.cpp b/Source/JavaScriptCore/wasm/WasmMemory.cpp >index 4c040d2da4f88d2e0d2c1702021685fe91d5ec71..a685f0ea3e4fcf905db2cc36d500aa759cb77b3f 100644 >--- a/Source/JavaScriptCore/wasm/WasmMemory.cpp >+++ b/Source/JavaScriptCore/wasm/WasmMemory.cpp >@@ -445,11 +445,11 @@ void Memory::registerInstance(Instance* instance) > size_t count = m_instances.size(); > for (size_t index = 0; index < count; index++) { > if (m_instances.at(index).get() == nullptr) { >- m_instances.at(index) = instance->createWeakPtr(); >+ m_instances.at(index) = makeWeakPtr(*instance); > return; > } > } >- m_instances.append(instance->createWeakPtr()); >+ m_instances.append(makeWeakPtr(*instance)); > } > > void Memory::dump(PrintStream& out) const >diff --git a/Source/WTF/wtf/WeakPtr.h b/Source/WTF/wtf/WeakPtr.h >index fd9ff76d9d205a7f1548ac51d8725d8d569bdcc9..eedd81f3f6c0b3efbd9be5d2b4884094be7eeda4 100644 >--- a/Source/WTF/wtf/WeakPtr.h >+++ b/Source/WTF/wtf/WeakPtr.h >@@ -123,6 +123,15 @@ private: > mutable RefPtr<WeakReference<T>> m_ref; > }; > >+template<typename T> class CanMakeWeakPtr { >+public: >+ const WeakPtrFactory<T>& weakPtrFactory() const { return m_weakFactory; } >+ WeakPtrFactory<T>& weakPtrFactory() { return m_weakFactory; } >+ >+private: >+ WeakPtrFactory<T> m_weakFactory; >+}; >+ > template<typename T, typename U> inline WeakReference<T>* weak_reference_upcast(WeakReference<U>* weakReference) > { > static_assert(std::is_convertible<U*, T*>::value, "U* must be convertible to T*"); >@@ -201,6 +210,7 @@ template<typename T, typename U> inline bool operator!=(T* a, const WeakPtr<U>& > > } // namespace WTF > >+using WTF::CanMakeWeakPtr; > using WTF::WeakPtr; > using WTF::WeakPtrFactory; > using WTF::WeakReference; >diff --git a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h b/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h >index 3d8cc9569f33048721b3c086ba5d8c2b076ad400..f28af95c16abff9cbeea1583666b05959abbe8ea 100644 >--- a/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h >+++ b/Source/WebCore/Modules/credentialmanagement/CredentialsMessenger.h >@@ -70,7 +70,7 @@ using CreationCompletionHandler = CompletionHandler<void(ExceptionOr<CreationRet > using RequestCompletionHandler = CompletionHandler<void(ExceptionOr<AssertionReturnBundle>&&)>; > using QueryCompletionHandler = CompletionHandler<void(bool)>; > >-class CredentialsMessenger { >+class CredentialsMessenger : public CanMakeWeakPtr<CredentialsMessenger> { > WTF_MAKE_FAST_ALLOCATED; > WTF_MAKE_NONCOPYABLE(CredentialsMessenger); > public: >@@ -87,8 +87,6 @@ public: > virtual void getAssertionReply(uint64_t messageId, const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) = 0; > virtual void isUserVerifyingPlatformAuthenticatorAvailableReply(uint64_t messageId, bool) = 0; > >- auto& weakPtrFactory() const { return m_weakFactory; } >- > protected: > virtual ~CredentialsMessenger() = default; > >@@ -100,8 +98,6 @@ protected: > WEBCORE_EXPORT QueryCompletionHandler takeQueryCompletionHandler(uint64_t); > > private: >- WeakPtrFactory<CredentialsMessenger> m_weakFactory; >- > enum CallBackClassifier : uint64_t { > Creation = 0x01, > Request = 0x02, >diff --git a/Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp b/Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp >index 9d8f0cfe899d5f7c939acea1b41183e945908412..71f438cf786c76d7b587215597668b62361b5993 100644 >--- a/Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp >+++ b/Source/WebCore/Modules/credentialmanagement/NavigatorCredentials.cpp >@@ -56,7 +56,7 @@ CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator) > { > if (!navigator.frame() || !navigator.frame()->document()) > return nullptr; >- return NavigatorCredentials::from(&navigator)->credentials(navigator.frame()->document()->createWeakPtr()); >+ return NavigatorCredentials::from(&navigator)->credentials(makeWeakPtr(*navigator.frame()->document())); > } > > NavigatorCredentials* NavigatorCredentials::from(Navigator* navigator) >diff --git a/Source/WebCore/Modules/encryptedmedia/CDM.cpp b/Source/WebCore/Modules/encryptedmedia/CDM.cpp >index a2bd44cc62baf92d1dd01199cfcaa11d2f3b6eeb..34cf3d367818289853556a673caceca7a7af830f 100644 >--- a/Source/WebCore/Modules/encryptedmedia/CDM.cpp >+++ b/Source/WebCore/Modules/encryptedmedia/CDM.cpp >@@ -106,7 +106,7 @@ void CDM::doSupportedConfigurationStep(MediaKeySystemConfiguration&& candidateCo > return; > } > >- auto consentCallback = [weakThis = createWeakPtr(), callback = WTFMove(callback)] (ConsentStatus status, MediaKeySystemConfiguration&& configuration, MediaKeysRestrictions&& restrictions) mutable { >+ auto consentCallback = [weakThis = makeWeakPtr(*this), callback = WTFMove(callback)] (ConsentStatus status, MediaKeySystemConfiguration&& configuration, MediaKeysRestrictions&& restrictions) mutable { > if (!weakThis) { > callback(std::nullopt); > return; >@@ -511,7 +511,7 @@ void CDM::getConsentStatus(MediaKeySystemConfiguration&& accumulatedConfiguratio > // NOTE: In the future, these checks belowe will involve asking the page client, possibly across a process boundary. > // They will by necessity be asynchronous with callbacks. For now, imply this behavior by performing it in an async task. > >- m_scriptExecutionContext->postTask([this, weakThis = createWeakPtr(), accumulatedConfiguration = WTFMove(accumulatedConfiguration), restrictions = WTFMove(restrictions), callback = WTFMove(callback)] (ScriptExecutionContext&) mutable { >+ m_scriptExecutionContext->postTask([this, weakThis = makeWeakPtr(*this), accumulatedConfiguration = WTFMove(accumulatedConfiguration), restrictions = WTFMove(restrictions), callback = WTFMove(callback)] (ScriptExecutionContext&) mutable { > if (!weakThis || !m_private) { > callback(ConsentStatus::ConsentDenied, WTFMove(accumulatedConfiguration), WTFMove(restrictions)); > return; >diff --git a/Source/WebCore/Modules/encryptedmedia/CDM.h b/Source/WebCore/Modules/encryptedmedia/CDM.h >index 4bf7b687885fcf2a21a550d631f5ea9bc3141963..e1558c5c2b04f3ebf9b56bcac9c07576897e407d 100644 >--- a/Source/WebCore/Modules/encryptedmedia/CDM.h >+++ b/Source/WebCore/Modules/encryptedmedia/CDM.h >@@ -49,7 +49,7 @@ class Document; > class ScriptExecutionContext; > class SharedBuffer; > >-class CDM : public RefCounted<CDM>, private ContextDestructionObserver { >+class CDM : public RefCounted<CDM>, public CanMakeWeakPtr<CDM>, private ContextDestructionObserver { > public: > static bool supportsKeySystem(const String&); > static bool isPersistentType(MediaKeySessionType); >@@ -101,13 +101,10 @@ 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(*this); } >- > using ConsentStatusCallback = WTF::Function<void(ConsentStatus, MediaKeySystemConfiguration&&, MediaKeysRestrictions&&)>; > void getConsentStatus(MediaKeySystemConfiguration&& accumulatedConfiguration, MediaKeysRestrictions&&, ConsentStatusCallback&&); > String m_keySystem; > std::unique_ptr<CDMPrivate> m_private; >- WeakPtrFactory<CDM> m_weakPtrFactory; > }; > > } >diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp b/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp >index 77c37719811819e20c70bf1cfaccf6a842e32161..9427cd423640d1eeb59323fbcc7acb9675d665c9 100644 >--- a/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp >+++ b/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp >@@ -194,7 +194,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(*this), 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 = makeWeakPtr(*this), promise = WTFMove(promise)] (Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable { > if (!weakThis) > return; > >@@ -287,7 +287,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(*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 { >+ m_instance->loadSession(m_sessionType, *sanitizedSessionId, origin, [this, weakThis = makeWeakPtr(*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. >@@ -388,7 +388,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(*this), 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 = makeWeakPtr(*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; > >@@ -500,7 +500,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(*this), promise = WTFMove(promise)] () mutable { >+ m_instance->closeSession(m_sessionId, [this, weakThis = makeWeakPtr(*this), promise = WTFMove(promise)] () mutable { > if (!weakThis) > return; > >@@ -538,7 +538,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(*this), promise = WTFMove(promise)] (CDMInstance::KeyStatusVector&& keys, std::optional<Ref<SharedBuffer>>&& message, CDMInstance::SuccessValue succeeded) mutable { >+ m_instance->removeSessionData(m_sessionId, m_sessionType, [this, weakThis = makeWeakPtr(*this), promise = WTFMove(promise)] (CDMInstance::KeyStatusVector&& keys, std::optional<Ref<SharedBuffer>>&& message, CDMInstance::SuccessValue succeeded) mutable { > if (!weakThis) > return; > >diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h b/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h >index ecc57b450cdabfc58e607451ca3a0e139dbc0a7b..0d1900e31bc7bd4917e826b610331ec588c95132 100644 >--- a/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h >+++ b/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h >@@ -52,7 +52,7 @@ class MediaKeyStatusMap; > class MediaKeys; > class SharedBuffer; > >-class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CDMInstanceClient { >+class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CanMakeWeakPtr<MediaKeySession>, public CDMInstanceClient { > public: > static Ref<MediaKeySession> create(ScriptExecutionContext&, WeakPtr<MediaKeys>&&, MediaKeySessionType, bool useDistinctiveIdentifier, Ref<CDM>&&, Ref<CDMInstance>&&); > virtual ~MediaKeySession(); >@@ -117,7 +117,6 @@ private: > double m_firstDecryptTime { 0 }; > double m_latestDecryptTime { 0 }; > Vector<std::pair<Ref<SharedBuffer>, MediaKeyStatus>> m_statuses; >- WeakPtrFactory<MediaKeySession> m_weakPtrFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp b/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp >index bef36a32de1feb5caa40187b6e1561815b71f3cb..39fbb80e976146cb78a624f71b2ae9f05bab2a2a 100644 >--- a/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp >+++ b/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp >@@ -67,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(*this), sessionType, m_useDistinctiveIdentifier, m_implementation.copyRef(), m_instance.copyRef()); >+ auto session = MediaKeySession::create(context, makeWeakPtr(*this), sessionType, m_useDistinctiveIdentifier, m_implementation.copyRef(), m_instance.copyRef()); > m_sessions.append(session.copyRef()); > return WTFMove(session); > } >diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeys.h b/Source/WebCore/Modules/encryptedmedia/MediaKeys.h >index 73c9fb2aa7d3fdf9424a15a265f78e67dbfa357f..914614de719f375307bcb8b7d8ce5b30a0067158 100644 >--- a/Source/WebCore/Modules/encryptedmedia/MediaKeys.h >+++ b/Source/WebCore/Modules/encryptedmedia/MediaKeys.h >@@ -46,7 +46,7 @@ class CDMInstance; > class BufferSource; > class MediaKeySession; > >-class MediaKeys : public RefCounted<MediaKeys> { >+class MediaKeys : public RefCounted<MediaKeys>, public CanMakeWeakPtr<MediaKeys> { > public: > using KeySessionType = MediaKeySessionType; > >@@ -77,7 +77,6 @@ protected: > Ref<CDM> m_implementation; > Ref<CDMInstance> m_instance; > >- WeakPtrFactory<MediaKeys> m_weakPtrFactory; > Vector<Ref<MediaKeySession>> m_sessions; > Vector<CDMClient*> m_cdmClients; > GenericTaskQueue<Timer> m_taskQueue; >diff --git a/Source/WebCore/Modules/gamepad/GamepadManager.cpp b/Source/WebCore/Modules/gamepad/GamepadManager.cpp >index b21a0d57d6ddba75ac0e5e512b1f798c388cd137..3d30ec7a59f242c456d54c579e2b195990f41a6e 100644 >--- a/Source/WebCore/Modules/gamepad/GamepadManager.cpp >+++ b/Source/WebCore/Modules/gamepad/GamepadManager.cpp >@@ -82,7 +82,7 @@ void GamepadManager::platformGamepadDisconnected(PlatformGamepad& platformGamepa > { > Vector<WeakPtr<DOMWindow>> weakWindows; > for (auto* domWindow : m_domWindows) >- weakWindows.append(domWindow->createWeakPtr()); >+ weakWindows.append(makeWeakPtr(*domWindow)); > > HashSet<NavigatorGamepad*> notifiedNavigators; > >@@ -144,7 +144,7 @@ void GamepadManager::makeGamepadVisible(PlatformGamepad& platformGamepad, HashSe > > Vector<WeakPtr<DOMWindow>> weakWindows; > for (auto* domWindow : m_domWindows) >- weakWindows.append(domWindow->createWeakPtr()); >+ weakWindows.append(makeWeakPtr(*domWindow)); > > for (auto& window : weakWindows) { > // Event dispatch might have made this window go away. >diff --git a/Source/WebCore/Modules/mediastream/MediaDevices.cpp b/Source/WebCore/Modules/mediastream/MediaDevices.cpp >index 0d82fc354e8a115fa8c273353e7e7d41bc4d3684..af3bf13229497c099554626ca2389ecb6aca1a85 100644 >--- a/Source/WebCore/Modules/mediastream/MediaDevices.cpp >+++ b/Source/WebCore/Modules/mediastream/MediaDevices.cpp >@@ -50,7 +50,7 @@ inline MediaDevices::MediaDevices(Document& document) > : ContextDestructionObserver(&document) > , m_scheduledEventTimer(*this, &MediaDevices::scheduledEventTimerFired) > { >- m_deviceChangedToken = RealtimeMediaSourceCenter::singleton().addDevicesChangedObserver([weakThis = createWeakPtr(), this]() { >+ m_deviceChangedToken = RealtimeMediaSourceCenter::singleton().addDevicesChangedObserver([weakThis = makeWeakPtr(*this), this]() { > > if (!weakThis) > return; >diff --git a/Source/WebCore/Modules/mediastream/MediaDevices.h b/Source/WebCore/Modules/mediastream/MediaDevices.h >index 04cc6059ba36d6fbbdca1ff7c86791b3154bba30..ae35d5e94d0ba76910154e8dc10ee3da8ff8604e 100644 >--- a/Source/WebCore/Modules/mediastream/MediaDevices.h >+++ b/Source/WebCore/Modules/mediastream/MediaDevices.h >@@ -49,7 +49,7 @@ class MediaStream; > > struct MediaTrackSupportedConstraints; > >-class MediaDevices : public RefCounted<MediaDevices>, public ContextDestructionObserver, public EventTargetWithInlineData { >+class MediaDevices : public RefCounted<MediaDevices>, public ContextDestructionObserver, public EventTargetWithInlineData, public CanMakeWeakPtr<MediaDevices> { > public: > static Ref<MediaDevices> create(Document&); > >@@ -90,11 +90,8 @@ private: > void refEventTarget() override { ref(); } > void derefEventTarget() override { deref(); } > >- WeakPtr<MediaDevices> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > Timer m_scheduledEventTimer; > std::optional<RealtimeMediaSourceCenter::DevicesChangedObserverToken> m_deviceChangedToken; >- WeakPtrFactory<MediaDevices> m_weakPtrFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >index 86769425f75ed5d51a6de721ab75d28ee5618512..b2a8f0b1708116a08c321e79306c16a43fbd1515 100644 >--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp >@@ -277,7 +277,7 @@ void MediaStreamTrack::applyConstraints(const std::optional<MediaTrackConstraint > { > m_promise = WTFMove(promise); > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > auto failureHandler = [weakThis] (const String& failedConstraint, const String& message) { > if (!weakThis || !weakThis->m_promise) > return; >diff --git a/Source/WebCore/Modules/mediastream/MediaStreamTrack.h b/Source/WebCore/Modules/mediastream/MediaStreamTrack.h >index da1b1c0607b87a199c633a29bdc4d44dce727483..515acc142e7d2de3c6cbe9ac93e4594ebfbc2be2 100644 >--- a/Source/WebCore/Modules/mediastream/MediaStreamTrack.h >+++ b/Source/WebCore/Modules/mediastream/MediaStreamTrack.h >@@ -50,6 +50,7 @@ class MediaStreamTrack : > public RefCounted<MediaStreamTrack>, > public ActiveDOMObject, > public EventTargetWithInlineData, >+ public CanMakeWeakPtr<MediaStreamTrack>, > private MediaProducer, > private MediaStreamTrackPrivate::Observer { > public: >@@ -169,14 +170,11 @@ private: > void trackSettingsChanged(MediaStreamTrackPrivate&) final; > void trackEnabledChanged(MediaStreamTrackPrivate&) final; > >- WeakPtr<MediaStreamTrack> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > Vector<Observer*> m_observers; > Ref<MediaStreamTrackPrivate> m_private; > > MediaTrackConstraints m_constraints; > std::optional<DOMPromiseDeferred<void>> m_promise; >- WeakPtrFactory<MediaStreamTrack> m_weakPtrFactory; > GenericTaskQueue<ScriptExecutionContext> m_taskQueue; > > bool m_ended { false }; >diff --git a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h b/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h >index e19b5d9c2bf5acee222749a66e213048ed8fbfda..2ae4035e982e2b6fd83058991201761ac2e1225d 100644 >--- a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h >+++ b/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.h >@@ -44,7 +44,7 @@ using ExceptionCallback = Function<void(const WebCore::ExceptionData&)>; > typedef void (^CompletionBlock)(SecKeyRef _Nullable referenceKey, NSArray * _Nullable certificates, NSError * _Nullable error); > > // FIXME(182769): LocalAuthenticator should belongs to WebKit. However, we need unit tests. >-class WEBCORE_EXPORT LocalAuthenticator { >+class WEBCORE_EXPORT LocalAuthenticator : public CanMakeWeakPtr<LocalAuthenticator> { > WTF_MAKE_NONCOPYABLE(LocalAuthenticator); > public: > LocalAuthenticator(); >@@ -57,8 +57,6 @@ public: > protected: > // Apple Attestation is moved into this virtual method such that it can be overrided by self attestation for testing. > virtual void issueClientCertificate(const String& rpId, const String& username, const Vector<uint8_t>& hash, CompletionBlock _Nonnull) const; >- >- WeakPtrFactory<LocalAuthenticator> m_weakFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm b/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm >index 74a19a37ad580c7c42698f9961bf42bc051450f2..3a740ed295d1469369079809461849d2572a8d3e 100644 >--- a/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm >+++ b/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm >@@ -186,7 +186,7 @@ void LocalAuthenticator::makeCredential(const Vector<uint8_t>& hash, const Publi > > NSString *reason = [NSString stringWithFormat:@"Allow %@ to create a public key credential for %@", (id)options.rp.id, (id)options.user.name]; > // FIXME(183534): Optimize the following nested callbacks and threading. >- [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:BlockPtr<void(BOOL, NSError *)>::fromCallable([weakThis = m_weakFactory.createWeakPtr(*this), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), options = crossThreadCopy(options), hash] (BOOL success, NSError *error) mutable { >+ [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:reason reply:BlockPtr<void(BOOL, NSError *)>::fromCallable([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), options = crossThreadCopy(options), hash] (BOOL success, NSError *error) mutable { > ASSERT(!isMainThread()); > if (!success || error) { > LOG_ERROR("Couldn't authenticate with biometrics: %@", error); >diff --git a/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.h b/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.h >index 9226e10dd9d73d9f5cb6ca90a60206a5e4e11b1a..5251bb7f6bccf0efbb0f4348471f32360a1b516e 100644 >--- a/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.h >+++ b/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.h >@@ -32,7 +32,7 @@ > > namespace PAL { > >-class SystemSleepListenerMac : public SystemSleepListener { >+class SystemSleepListenerMac : public SystemSleepListener, public CanMakeWeakPtr<SystemSleepListenerMac> { > WTF_MAKE_FAST_ALLOCATED; > protected: > SystemSleepListenerMac(Client&); >@@ -40,7 +40,6 @@ protected: > > friend std::unique_ptr<SystemSleepListener> SystemSleepListener::create(Client&); > >- WeakPtrFactory<SystemSleepListenerMac> m_weakPtrFactory; > id m_sleepObserver; > id m_wakeObserver; > }; >diff --git a/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.mm b/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.mm >index 6d53a7bfd0d8f7aced12e7cdef216e28cd29fdff..17f646c93f9a0b232fa87257c9535b40988030d5 100644 >--- a/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.mm >+++ b/Source/WebCore/PAL/pal/system/mac/SystemSleepListenerMac.mm >@@ -46,7 +46,7 @@ SystemSleepListenerMac::SystemSleepListenerMac(Client& client) > NSNotificationCenter *center = [[NSWorkspace sharedWorkspace] notificationCenter]; > NSOperationQueue *queue = [NSOperationQueue mainQueue]; > >- auto weakThis = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > > m_sleepObserver = [center addObserverForName:NSWorkspaceWillSleepNotification object:nil queue:queue usingBlock:^(NSNotification *) { > callOnMainThread([weakThis] { >diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.h b/Source/WebCore/accessibility/AccessibilityRenderObject.h >index 81bb5beb190b60c0deebf83bf5d8009c4b524ed8..48af65ad0d14d9886de83b4e6b354e165f6ca32e 100644 >--- a/Source/WebCore/accessibility/AccessibilityRenderObject.h >+++ b/Source/WebCore/accessibility/AccessibilityRenderObject.h >@@ -52,7 +52,7 @@ class RenderView; > class VisibleSelection; > class Widget; > >-class AccessibilityRenderObject : public AccessibilityNodeObject { >+class AccessibilityRenderObject : public AccessibilityNodeObject, public CanMakeWeakPtr<AccessibilityRenderObject> { > public: > static Ref<AccessibilityRenderObject> create(RenderObject*); > virtual ~AccessibilityRenderObject(); >@@ -200,8 +200,6 @@ public: > AccessibilityRole roleValueForMSAA() const override; > > String passwordFieldValue() const override; >- >- WeakPtr<AccessibilityRenderObject> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > > protected: > explicit AccessibilityRenderObject(RenderObject*); >@@ -220,7 +218,6 @@ protected: > WeakPtr<RenderObject> m_renderer; > > private: >- WeakPtrFactory<AccessibilityRenderObject> m_weakPtrFactory; > bool isAccessibilityRenderObject() const final { return true; } > void ariaListboxSelectedChildren(AccessibilityChildrenVector&); > void ariaListboxVisibleChildren(AccessibilityChildrenVector&); >diff --git a/Source/WebCore/accessibility/AccessibilitySVGRoot.cpp b/Source/WebCore/accessibility/AccessibilitySVGRoot.cpp >index f14dd678d456c85c4cddd03200ed399bed2778fc..3236af0222732a5d25d5ba84251d51c081a03dd3 100644 >--- a/Source/WebCore/accessibility/AccessibilitySVGRoot.cpp >+++ b/Source/WebCore/accessibility/AccessibilitySVGRoot.cpp >@@ -45,12 +45,9 @@ Ref<AccessibilitySVGRoot> AccessibilitySVGRoot::create(RenderObject* renderer) > return adoptRef(*new AccessibilitySVGRoot(renderer)); > } > >-void AccessibilitySVGRoot::setParent(AccessibilityRenderObject *parent) >+void AccessibilitySVGRoot::setParent(AccessibilityRenderObject* parent) > { >- if (parent) >- m_parent = parent->createWeakPtr(); >- else >- m_parent = nullptr; >+ m_parent = makeWeakPtr(parent); > } > > AccessibilityObject* AccessibilitySVGRoot::parentObject() const >diff --git a/Source/WebCore/crypto/SubtleCrypto.cpp b/Source/WebCore/crypto/SubtleCrypto.cpp >index fc6aa1277257da130f2445aa1b653417b1097a9a..a0d0d9ab9489025861b30af5643816c50aa82728 100644 >--- a/Source/WebCore/crypto/SubtleCrypto.cpp >+++ b/Source/WebCore/crypto/SubtleCrypto.cpp >@@ -543,7 +543,7 @@ void SubtleCrypto::encrypt(JSC::ExecState& state, AlgorithmIdentifier&& algorith > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](const Vector<uint8_t>& cipherText) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) > fulfillPromiseWithArrayBuffer(promise.releaseNonNull(), cipherText.data(), cipherText.size()); >@@ -581,7 +581,7 @@ void SubtleCrypto::decrypt(JSC::ExecState& state, AlgorithmIdentifier&& algorith > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](const Vector<uint8_t>& plainText) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) > fulfillPromiseWithArrayBuffer(promise.releaseNonNull(), plainText.data(), plainText.size()); >@@ -619,7 +619,7 @@ void SubtleCrypto::sign(JSC::ExecState& state, AlgorithmIdentifier&& algorithmId > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](const Vector<uint8_t>& signature) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) > fulfillPromiseWithArrayBuffer(promise.releaseNonNull(), signature.data(), signature.size()); >@@ -658,7 +658,7 @@ void SubtleCrypto::verify(JSC::ExecState& state, AlgorithmIdentifier&& algorithm > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](bool result) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) > promise->resolve<IDLBoolean>(result); >@@ -686,7 +686,7 @@ void SubtleCrypto::digest(JSC::ExecState& state, AlgorithmIdentifier&& algorithm > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](const Vector<uint8_t>& digest) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) > fulfillPromiseWithArrayBuffer(promise.releaseNonNull(), digest.data(), digest.size()); >@@ -714,7 +714,7 @@ void SubtleCrypto::generateKey(JSC::ExecState& state, AlgorithmIdentifier&& algo > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](KeyOrKeyPair&& keyOrKeyPair) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) { > WTF::switchOn(keyOrKeyPair, >@@ -795,7 +795,7 @@ void SubtleCrypto::deriveKey(JSC::ExecState& state, AlgorithmIdentifier&& algori > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer, importAlgorithm, importParams = WTFMove(importParams), extractable, keyUsagesBitmap](const Vector<uint8_t>& derivedKey) mutable { > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395 > KeyData data = derivedKey; >@@ -846,7 +846,7 @@ void SubtleCrypto::deriveBits(JSC::ExecState& state, AlgorithmIdentifier&& algor > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](const Vector<uint8_t>& derivedKey) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) > fulfillPromiseWithArrayBuffer(promise.releaseNonNull(), derivedKey.data(), derivedKey.size()); >@@ -881,7 +881,7 @@ void SubtleCrypto::importKey(JSC::ExecState& state, KeyFormat format, KeyDataVar > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](CryptoKey& key) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) { > if ((key.type() == CryptoKeyType::Private || key.type() == CryptoKeyType::Secret) && !key.usagesBitmap()) { >@@ -918,7 +918,7 @@ void SubtleCrypto::exportKey(KeyFormat format, CryptoKey& key, Ref<DeferredPromi > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer](SubtleCrypto::KeyFormat format, KeyData&& key) mutable { > if (auto promise = getPromise(index, subtleCryptoWeakPointer)) { > switch (format) { >@@ -992,7 +992,7 @@ void SubtleCrypto::wrapKey(JSC::ExecState& state, KeyFormat format, CryptoKey& k > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer, wrapAlgorithm, wrappingKey = makeRef(wrappingKey), wrapParams = WTFMove(wrapParams), isEncryption, context, workQueue = m_workQueue.copyRef()](SubtleCrypto::KeyFormat format, KeyData&& key) mutable { > if (subtleCryptoWeakPointer) { > if (auto promise = subtleCryptoWeakPointer->m_pendingPromises.get(index)) { >@@ -1095,7 +1095,7 @@ void SubtleCrypto::unwrapKey(JSC::ExecState& state, KeyFormat format, BufferSour > > auto index = promise.ptr(); > m_pendingPromises.add(index, WTFMove(promise)); >- auto subtleCryptoWeakPointer = m_weakPtrFactory.createWeakPtr(*this); >+ auto subtleCryptoWeakPointer = makeWeakPtr(*this); > auto callback = [index, subtleCryptoWeakPointer, format, importAlgorithm, unwrappedKeyAlgorithm = WTFMove(unwrappedKeyAlgorithm), extractable, keyUsagesBitmap](const Vector<uint8_t>& bytes) mutable { > if (subtleCryptoWeakPointer) { > if (auto promise = subtleCryptoWeakPointer->m_pendingPromises.get(index)) { >diff --git a/Source/WebCore/crypto/SubtleCrypto.h b/Source/WebCore/crypto/SubtleCrypto.h >index caf48f989fab77c2d4bcee24b8cbb7ed178d6cba..04e603ef9654588f76ef9c82026264e367ab2f18 100644 >--- a/Source/WebCore/crypto/SubtleCrypto.h >+++ b/Source/WebCore/crypto/SubtleCrypto.h >@@ -52,7 +52,7 @@ class DeferredPromise; > > enum class CryptoKeyUsage; > >-class SubtleCrypto : public ContextDestructionObserver, public RefCounted<SubtleCrypto> { >+class SubtleCrypto : public ContextDestructionObserver, public RefCounted<SubtleCrypto>, public CanMakeWeakPtr<SubtleCrypto> { > public: > static Ref<SubtleCrypto> create(ScriptExecutionContext& context) { return adoptRef(*new SubtleCrypto(context)); } > ~SubtleCrypto(); >@@ -82,7 +82,6 @@ private: > > Ref<WorkQueue> m_workQueue; > HashMap<DeferredPromise*, Ref<DeferredPromise>> m_pendingPromises; >- WeakPtrFactory<SubtleCrypto> m_weakPtrFactory; > }; > > } >diff --git a/Source/WebCore/css/CSSFontFace.cpp b/Source/WebCore/css/CSSFontFace.cpp >index 90a1808b899bd92fc68b7345831d0749376d840a..f7d775ffbba76b80ceee71deec5cf4b67e2ff31c 100644 >--- a/Source/WebCore/css/CSSFontFace.cpp >+++ b/Source/WebCore/css/CSSFontFace.cpp >@@ -92,7 +92,7 @@ CSSFontFace::CSSFontFace(CSSFontSelector* fontSelector, StyleRuleFontFace* cssCo > : m_timeoutTimer(*this, &CSSFontFace::timeoutFired) > , m_fontSelector(fontSelector) > , m_cssConnection(cssConnection) >- , m_wrapper(wrapper ? wrapper->createWeakPtr() : WeakPtr<FontFace>()) >+ , m_wrapper(makeWeakPtr(wrapper)) > , m_isLocalFallback(isLocalFallback) > , m_mayBePurged(!wrapper) > { >@@ -563,14 +563,14 @@ Ref<FontFace> CSSFontFace::wrapper() > return *m_wrapper.get(); > > auto wrapper = FontFace::create(*this); >- m_wrapper = wrapper->createWeakPtr(); >+ m_wrapper = makeWeakPtr(wrapper.get()); > initializeWrapper(); > return wrapper; > } > > void CSSFontFace::setWrapper(FontFace& newWrapper) > { >- m_wrapper = newWrapper.createWeakPtr(); >+ m_wrapper = makeWeakPtr(newWrapper); > initializeWrapper(); > } > >diff --git a/Source/WebCore/css/DeprecatedCSSOMValue.h b/Source/WebCore/css/DeprecatedCSSOMValue.h >index 77e2e36c6924175e69872715d2f0dad8f0d52dd6..16bca96d0687fbccb2c7a0b518a2f81ea0e65cf1 100644 >--- a/Source/WebCore/css/DeprecatedCSSOMValue.h >+++ b/Source/WebCore/css/DeprecatedCSSOMValue.h >@@ -36,7 +36,7 @@ > > namespace WebCore { > >-class DeprecatedCSSOMValue : public RefCounted<DeprecatedCSSOMValue> { >+class DeprecatedCSSOMValue : public RefCounted<DeprecatedCSSOMValue>, public CanMakeWeakPtr<DeprecatedCSSOMValue> { > public: > // Exactly match the IDL. No reason to add anything if it's not in the IDL. > enum Type { >@@ -65,8 +65,6 @@ public: > > CSSStyleDeclaration& owner() const { return m_owner; } > >- WeakPtrFactory<DeprecatedCSSOMValue>& weakPtrFactory() { return m_weakPtrFactory; } >- > protected: > static const size_t ClassTypeBits = 2; > enum DeprecatedClassType { >@@ -95,7 +93,6 @@ protected: > unsigned m_classType : ClassTypeBits; // ClassType > > Ref<CSSStyleDeclaration> m_owner; >- WeakPtrFactory<DeprecatedCSSOMValue> m_weakPtrFactory; > }; > > class DeprecatedCSSOMComplexValue : public DeprecatedCSSOMValue { >diff --git a/Source/WebCore/css/FontFace.cpp b/Source/WebCore/css/FontFace.cpp >index 581f5e8c9e5aa1130acb6fbc882a134aa5bada54..1fffb175de425e2111530560268a81c23733d1a8 100644 >--- a/Source/WebCore/css/FontFace.cpp >+++ b/Source/WebCore/css/FontFace.cpp >@@ -142,11 +142,6 @@ FontFace::~FontFace() > m_backing->removeClient(*this); > } > >-WeakPtr<FontFace> FontFace::createWeakPtr() >-{ >- return m_weakPtrFactory.createWeakPtr(*this); >-} >- > RefPtr<CSSValue> FontFace::parseString(const String& string, CSSPropertyID propertyID) > { > // FIXME: Should use the Document to get the right parsing mode. >diff --git a/Source/WebCore/css/FontFace.h b/Source/WebCore/css/FontFace.h >index 3480030f598ad7c774df85e4a180d755a4fba489..3d9a0ec1c9adaac821b67401b8796ea7cb678af6 100644 >--- a/Source/WebCore/css/FontFace.h >+++ b/Source/WebCore/css/FontFace.h >@@ -38,7 +38,7 @@ class ArrayBufferView; > > namespace WebCore { > >-class FontFace final : public RefCounted<FontFace>, private CSSFontFace::Client { >+class FontFace final : public RefCounted<FontFace>, public CanMakeWeakPtr<FontFace>, private CSSFontFace::Client { > public: > struct Descriptors { > String style; >@@ -88,8 +88,6 @@ public: > > void fontStateChanged(CSSFontFace&, CSSFontFace::Status oldState, CSSFontFace::Status newState) final; > >- WeakPtr<FontFace> createWeakPtr(); >- > void ref() final { RefCounted::ref(); } > void deref() final { RefCounted::deref(); } > >@@ -100,7 +98,6 @@ private: > // Callback for LoadedPromise. > FontFace& loadedPromiseResolve(); > >- WeakPtrFactory<FontFace> m_weakPtrFactory; > Ref<CSSFontFace> m_backing; > LoadedPromise m_loadedPromise; > }; >diff --git a/Source/WebCore/css/MediaQueryEvaluator.cpp b/Source/WebCore/css/MediaQueryEvaluator.cpp >index 8c793c2b786903a582c52a08eeab7ccf45354295..cc6eb1b2469769458efef306597b344eea939577 100644 >--- a/Source/WebCore/css/MediaQueryEvaluator.cpp >+++ b/Source/WebCore/css/MediaQueryEvaluator.cpp >@@ -110,7 +110,7 @@ MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m > > MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, const Document& document, const RenderStyle* style) > : m_mediaType(acceptedMediaType) >- , m_document(const_cast<Document&>(document).createWeakPtr()) >+ , m_document(makeWeakPtr(const_cast<Document&>(document))) > , m_style(style) > { > } >diff --git a/Source/WebCore/css/StyleSheetContents.h b/Source/WebCore/css/StyleSheetContents.h >index 0117eaae5f3c2790356c3581132f1c86823bf2fb..490803d4f3c033398104e77a9e102997d94e28fa 100644 >--- a/Source/WebCore/css/StyleSheetContents.h >+++ b/Source/WebCore/css/StyleSheetContents.h >@@ -43,7 +43,7 @@ class StyleRuleBase; > class StyleRuleImport; > class StyleRuleNamespace; > >-class StyleSheetContents final : public RefCounted<StyleSheetContents> { >+class StyleSheetContents final : public RefCounted<StyleSheetContents>, public CanMakeWeakPtr<StyleSheetContents> { > public: > static Ref<StyleSheetContents> create(const CSSParserContext& context = CSSParserContext(HTMLStandardMode)) > { >@@ -144,8 +144,6 @@ public: > > void shrinkToFit(); > >- WeakPtr<StyleSheetContents> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > WEBCORE_EXPORT StyleSheetContents(StyleRuleImport* ownerRule, const String& originalURL, const CSSParserContext&); > StyleSheetContents(const StyleSheetContents&); >@@ -175,8 +173,6 @@ private: > CSSParserContext m_parserContext; > > Vector<CSSStyleSheet*> m_clients; >- >- WeakPtrFactory<StyleSheetContents> m_weakPtrFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/css/parser/CSSDeferredParser.cpp b/Source/WebCore/css/parser/CSSDeferredParser.cpp >index 06469ea9f196fd2037d508aa85590637cd75cb4e..d34c19b01a1f99a6af0dcc0896ae5b18c33b3fb3 100644 >--- a/Source/WebCore/css/parser/CSSDeferredParser.cpp >+++ b/Source/WebCore/css/parser/CSSDeferredParser.cpp >@@ -35,7 +35,7 @@ namespace WebCore { > CSSDeferredParser::CSSDeferredParser(const CSSParserContext& context, const String& sheetText, StyleSheetContents& styleSheet) > : m_context(context) > , m_sheetText(sheetText) >- , m_styleSheet(styleSheet.createWeakPtr()) >+ , m_styleSheet(makeWeakPtr(styleSheet)) > { > } > >diff --git a/Source/WebCore/dom/DataTransferItemList.cpp b/Source/WebCore/dom/DataTransferItemList.cpp >index 8127194795f698e31e0636379352533d11d7b76a..cea8bc254c5b220e894f8e637e9416a5c385c119 100644 >--- a/Source/WebCore/dom/DataTransferItemList.cpp >+++ b/Source/WebCore/dom/DataTransferItemList.cpp >@@ -76,7 +76,7 @@ ExceptionOr<RefPtr<DataTransferItem>> DataTransferItemList::add(const String& da > > m_dataTransfer.setDataFromItemList(lowercasedType, data); > ASSERT(m_items); >- m_items->append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*this), lowercasedType)); >+ m_items->append(DataTransferItem::create(makeWeakPtr(*this), lowercasedType)); > return m_items->last().ptr(); > } > >@@ -85,7 +85,7 @@ RefPtr<DataTransferItem> DataTransferItemList::add(Ref<File>&& file) > if (!m_dataTransfer.canWriteData()) > return nullptr; > >- ensureItems().append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*this), file->type(), file.copyRef())); >+ ensureItems().append(DataTransferItem::create(makeWeakPtr(*this), file->type(), file.copyRef())); > m_dataTransfer.didAddFileToItemList(); > return m_items->last().ptr(); > } >@@ -136,11 +136,11 @@ Vector<Ref<DataTransferItem>>& DataTransferItemList::ensureItems() const > for (auto& type : m_dataTransfer.typesForItemList()) { > auto lowercasedType = type.convertToASCIILowercase(); > if (shouldExposeTypeInItemList(lowercasedType)) >- items.append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*const_cast<DataTransferItemList*>(this)), lowercasedType)); >+ items.append(DataTransferItem::create(makeWeakPtr(*const_cast<DataTransferItemList*>(this)), lowercasedType)); > } > > for (auto& file : m_dataTransfer.files().files()) >- items.append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*const_cast<DataTransferItemList*>(this)), file->type(), file.copyRef())); >+ items.append(DataTransferItem::create(makeWeakPtr(*const_cast<DataTransferItemList*>(this)), file->type(), file.copyRef())); > > m_items = WTFMove(items); > >@@ -185,7 +185,7 @@ void DataTransferItemList::didSetStringData(const String& type) > String lowercasedType = type.convertToASCIILowercase(); > removeStringItemOfLowercasedType(*m_items, type.convertToASCIILowercase()); > >- m_items->append(DataTransferItem::create(m_weakPtrFactory.createWeakPtr(*this), lowercasedType)); >+ m_items->append(DataTransferItem::create(makeWeakPtr(*this), lowercasedType)); > } > > } >diff --git a/Source/WebCore/dom/DataTransferItemList.h b/Source/WebCore/dom/DataTransferItemList.h >index 13120e54ad3680ae66983cffe2cca2d44bb67b8a..d25359abac9b536607dd133440fe93fdd116c8a3 100644 >--- a/Source/WebCore/dom/DataTransferItemList.h >+++ b/Source/WebCore/dom/DataTransferItemList.h >@@ -44,7 +44,7 @@ namespace WebCore { > class DataTransferItem; > class File; > >-class DataTransferItemList : public ScriptWrappable { >+class DataTransferItemList : public ScriptWrappable, public CanMakeWeakPtr<DataTransferItemList> { > WTF_MAKE_NONCOPYABLE(DataTransferItemList); WTF_MAKE_FAST_ALLOCATED; > public: > DataTransferItemList(DataTransfer&); >@@ -75,7 +75,6 @@ public: > private: > Vector<Ref<DataTransferItem>>& ensureItems() const; > >- WeakPtrFactory<DataTransferItemList> m_weakPtrFactory; > DataTransfer& m_dataTransfer; > mutable std::optional<Vector<Ref<DataTransferItem>>> m_items; > }; >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 50ddc9a160a637a457b16b0367cdb2b3cc4f7591..39a257d0491f4e166c30c4c44f7bab1d51a44b65 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -5821,7 +5821,7 @@ void Document::addMessage(MessageSource source, MessageLevel level, const String > > void Document::postTask(Task&& task) > { >- callOnMainThread([documentReference = m_weakFactory.createWeakPtr(*this), task = WTFMove(task)]() mutable { >+ callOnMainThread([documentReference = makeWeakPtr(*this), task = WTFMove(task)]() mutable { > ASSERT(isMainThread()); > > Document* document = documentReference.get(); >@@ -7559,7 +7559,7 @@ void Document::hasStorageAccess(Ref<DeferredPromise>&& promise) > if (Page* page = this->page()) { > auto iframeHost = securityOrigin.host(); > auto topHost = topSecurityOrigin.host(); >- page->chrome().client().hasStorageAccess(WTFMove(iframeHost), WTFMove(topHost), frameID.value(), pageID.value(), [documentReference = m_weakFactory.createWeakPtr(*this), promise = WTFMove(promise)] (bool hasAccess) { >+ page->chrome().client().hasStorageAccess(WTFMove(iframeHost), WTFMove(topHost), frameID.value(), pageID.value(), [documentReference = makeWeakPtr(*this), promise = WTFMove(promise)] (bool hasAccess) { > Document* document = documentReference.get(); > if (!document) > return; >@@ -7629,14 +7629,14 @@ void Document::requestStorageAccess(Ref<DeferredPromise>&& promise) > return; > } > >- page->chrome().client().requestStorageAccess(WTFMove(iframeHost), WTFMove(topHost), frameID.value(), pageID.value(), [documentReference = m_weakFactory.createWeakPtr(*this), promise = WTFMove(promise)] (bool wasGranted) mutable { >+ page->chrome().client().requestStorageAccess(WTFMove(iframeHost), WTFMove(topHost), frameID.value(), pageID.value(), [documentReference = makeWeakPtr(*this), promise = WTFMove(promise)] (bool wasGranted) mutable { > Document* document = documentReference.get(); > if (!document) > return; > > if (wasGranted) { > document->setHasFrameSpecificStorageAccess(true); >- MicrotaskQueue::mainThreadQueue().append(std::make_unique<VoidMicrotask>([documentReference = document->m_weakFactory.createWeakPtr(*document)] () { >+ MicrotaskQueue::mainThreadQueue().append(std::make_unique<VoidMicrotask>([documentReference = makeWeakPtr(*document)] () { > if (auto* document = documentReference.get()) > document->enableTemporaryTimeUserGesture(); > })); >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 499bacbe1a738727c17fdc5d720bc23bef416d66..0cb3c1c5842dd7d7bbf54207cb939c3c70046c44 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -321,6 +321,7 @@ class Document > , public TreeScope > , public ScriptExecutionContext > , public FontSelectorClient >+ , public CanMakeWeakPtr<Document> > , public FrameDestructionObserver > , public Supplementable<Document> > , public Logger::Observer { >@@ -799,7 +800,7 @@ public: > WEBCORE_EXPORT WindowProxy* windowProxy() const; > > Document& contextDocument() const; >- void setContextDocument(Document& document) { m_contextDocument = document.createWeakPtr(); } >+ void setContextDocument(Document& document) { m_contextDocument = makeWeakPtr(document); } > > // Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists. > void setWindowAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value, DOMWrapperWorld&); >@@ -1311,7 +1312,6 @@ 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(*this); } > > #if ENABLE(WIRELESS_PLAYBACK_TARGET) > void addPlaybackTargetPickerClient(MediaPlaybackTargetClient&); >@@ -1694,8 +1694,6 @@ private: > RenderPtr<RenderView> m_renderView; > mutable DocumentEventQueue m_eventQueue; > >- WeakPtrFactory<Document> m_weakFactory; >- > HashSet<MediaCanStartListener*> m_mediaCanStartListeners; > > #if ENABLE(FULLSCREEN_API) >diff --git a/Source/WebCore/dom/MessagePort.h b/Source/WebCore/dom/MessagePort.h >index cb97d11c885e86c8c11cb24ca4db459bbbc8754a..8eadf790b2ab16c2b67f7e847c279adbbd28c0c8 100644 >--- a/Source/WebCore/dom/MessagePort.h >+++ b/Source/WebCore/dom/MessagePort.h >@@ -44,13 +44,11 @@ namespace WebCore { > > class Frame; > >-class MessagePort final : public ActiveDOMObject, public EventTargetWithInlineData { >+class MessagePort final : public ActiveDOMObject, public EventTargetWithInlineData, public CanMakeWeakPtr<MessagePort> { > public: > static Ref<MessagePort> create(ScriptExecutionContext&, const MessagePortIdentifier& local, const MessagePortIdentifier& remote); > virtual ~MessagePort(); > >- auto& weakPtrFactory() const { return m_weakFactory; } >- > ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&); > > void start(); >@@ -115,8 +113,6 @@ private: > bool m_closed { false }; > bool m_entangled { true }; > >- WeakPtrFactory<MessagePort> m_weakFactory; >- > // Flags to manage querying the remote port for GC purposes > mutable bool m_mightBeEligibleForGC { false }; > mutable bool m_hasHadLocalActivitySinceLastCheck { false }; >diff --git a/Source/WebCore/html/HTMLImageElement.cpp b/Source/WebCore/html/HTMLImageElement.cpp >index 57399a4d4552c6e972d878e3d16b0c43870e8d48..abe006d03f92830375a146c7752b2f2a322c7bc5 100644 >--- a/Source/WebCore/html/HTMLImageElement.cpp >+++ b/Source/WebCore/html/HTMLImageElement.cpp >@@ -371,7 +371,7 @@ void HTMLImageElement::setPictureElement(HTMLPictureElement* pictureElement) > > if (!gPictureOwnerMap) > gPictureOwnerMap = new PictureOwnerMap(); >- gPictureOwnerMap->add(this, pictureElement->createWeakPtr()); >+ gPictureOwnerMap->add(this, makeWeakPtr(*pictureElement)); > } > > unsigned HTMLImageElement::width(bool ignorePendingStylesheets) >diff --git a/Source/WebCore/html/HTMLInputElement.h b/Source/WebCore/html/HTMLInputElement.h >index bf605dfc3dfb18af853dda6d2388ee00e0bfbf08..80a7e2285609aaa49f54da780dbec950b443f5ac 100644 >--- a/Source/WebCore/html/HTMLInputElement.h >+++ b/Source/WebCore/html/HTMLInputElement.h >@@ -55,7 +55,7 @@ struct InputElementClickState { > RefPtr<HTMLInputElement> checkedRadioButton; > }; > >-class HTMLInputElement : public HTMLTextFormControlElement { >+class HTMLInputElement : public HTMLTextFormControlElement, public CanMakeWeakPtr<HTMLInputElement> { > WTF_MAKE_ISO_ALLOCATED(HTMLInputElement); > public: > static Ref<HTMLInputElement> create(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); >@@ -343,8 +343,6 @@ public: > > ExceptionOr<void> setSelectionRangeForBindings(int start, int end, const String& direction); > >- auto& weakPtrFactory() const { return m_weakFactory; } >- > protected: > HTMLInputElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); > >@@ -485,7 +483,6 @@ private: > #if ENABLE(DATALIST_ELEMENT) > std::unique_ptr<ListAttributeTargetObserver> m_listAttributeTargetObserver; > #endif >- WeakPtrFactory<HTMLInputElement> m_weakFactory; > }; > > } >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 16270ea96e2238775ce410bac683eadc65947a0e..f6b5e361dd9a82416b1be257883f6370cd4c93e4 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -6910,7 +6910,7 @@ RefPtr<PlatformMediaResourceLoader> HTMLMediaElement::mediaPlayerCreateResourceL > { > auto mediaResourceLoader = adoptRef(*new MediaResourceLoader(document(), *this, crossOrigin())); > >- m_lastMediaResourceLoaderForTesting = mediaResourceLoader->createWeakPtr(); >+ m_lastMediaResourceLoaderForTesting = makeWeakPtr(mediaResourceLoader.get()); > > return WTFMove(mediaResourceLoader); > } >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index 237c360c3a8023a34240bfd390d1f555489a77bd..3ee881a6b4e294fdecd0e9eb21eb34c1327a7c0e 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -123,6 +123,7 @@ class HTMLMediaElement > : public HTMLElement > , public ActiveDOMObject > , public MediaControllerInterface >+ , public CanMakeWeakPtr<HTMLMediaElement> > , public PlatformMediaSessionClient > , private MediaCanStartListener > , private MediaPlayerClient >@@ -146,7 +147,6 @@ class HTMLMediaElement > { > WTF_MAKE_ISO_ALLOCATED(HTMLMediaElement); > public: >- WeakPtr<HTMLMediaElement> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } > RefPtr<MediaPlayer> player() const { return m_player; } > > virtual bool isVideo() const { return false; } >@@ -922,7 +922,6 @@ private: > const Logger& mediaPlayerLogger() final { return logger(); } > #endif > >- WeakPtrFactory<HTMLMediaElement> m_weakFactory; > Timer m_pendingActionTimer; > Timer m_progressEventTimer; > Timer m_playbackProgressTimer; >diff --git a/Source/WebCore/html/HTMLPictureElement.h b/Source/WebCore/html/HTMLPictureElement.h >index 3d507cec322cb693b9ebee3c5f487b9a1e852329..c6da3576c48210da481311b7386b07dd7dfafb1d 100644 >--- a/Source/WebCore/html/HTMLPictureElement.h >+++ b/Source/WebCore/html/HTMLPictureElement.h >@@ -30,7 +30,7 @@ > > namespace WebCore { > >-class HTMLPictureElement final : public HTMLElement { >+class HTMLPictureElement final : public HTMLElement, public CanMakeWeakPtr<HTMLPictureElement> { > WTF_MAKE_ISO_ALLOCATED(HTMLPictureElement); > public: > static Ref<HTMLPictureElement> create(const QualifiedName&, Document&); >@@ -44,8 +44,6 @@ public: > > bool viewportChangeAffectedPicture() const; > >- WeakPtr<HTMLPictureElement> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } >- > #if USE(SYSTEM_PREVIEW) > WEBCORE_EXPORT bool isSystemPreviewImage() const; > #endif >@@ -55,7 +53,6 @@ private: > > void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final; > >- WeakPtrFactory<HTMLPictureElement> m_weakFactory; > Vector<MediaQueryResult> m_viewportDependentMediaQueryResults; > }; > >diff --git a/Source/WebCore/html/parser/HTMLResourcePreloader.h b/Source/WebCore/html/parser/HTMLResourcePreloader.h >index aa2c782de05837f5228639f96b0832e33b5ccab1..dae7464b38387c475618af3169ef31f5f047deeb 100644 >--- a/Source/WebCore/html/parser/HTMLResourcePreloader.h >+++ b/Source/WebCore/html/parser/HTMLResourcePreloader.h >@@ -72,7 +72,7 @@ private: > > typedef Vector<std::unique_ptr<PreloadRequest>> PreloadRequestStream; > >-class HTMLResourcePreloader { >+class HTMLResourcePreloader : public CanMakeWeakPtr<HTMLResourcePreloader> { > WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED; > public: > explicit HTMLResourcePreloader(Document& document) >@@ -83,11 +83,8 @@ public: > void preload(PreloadRequestStream); > void preload(std::unique_ptr<PreloadRequest>); > >- WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } >- > private: > Document& m_document; >- WeakPtrFactory<HTMLResourcePreloader> m_weakFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/layout/layouttree/LayoutBox.h b/Source/WebCore/layout/layouttree/LayoutBox.h >index 6215b39eecde022532a1403d2c91bb96772e81d1..9db2060162207896ecaea20c40a552e173b75e8c 100644 >--- a/Source/WebCore/layout/layouttree/LayoutBox.h >+++ b/Source/WebCore/layout/layouttree/LayoutBox.h >@@ -39,7 +39,7 @@ namespace Layout { > class Container; > class TreeBuilder; > >-class Box { >+class Box : public CanMakeWeakPtr<Box> { > WTF_MAKE_ISO_ALLOCATED(Box); > public: > friend class TreeBuilder; >@@ -94,7 +94,6 @@ public: > bool isPaddingApplicable() const; > > const RenderStyle& style() const { return m_style; } >- auto& weakPtrFactory() const { return m_weakFactory; } > > std::optional<const Replaced> replaced() const { return m_replaced; } > >@@ -129,7 +128,6 @@ private: > void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; } > void setPreviousSibling(Box& previousSibling) { m_previousSibling = &previousSibling; } > >- WeakPtrFactory<Box> m_weakFactory; > RenderStyle m_style; > std::optional<ElementAttributes> m_elementAttributes; > >diff --git a/Source/WebCore/loader/FormState.h b/Source/WebCore/loader/FormState.h >index 77584329af16424650c00db8a793d9d955f5050f..6ed8becb14592fe7916e99bf8b0f15efd9e9df62 100644 >--- a/Source/WebCore/loader/FormState.h >+++ b/Source/WebCore/loader/FormState.h >@@ -41,7 +41,7 @@ enum FormSubmissionTrigger { SubmittedByJavaScript, NotSubmittedByJavaScript }; > > using StringPairVector = Vector<std::pair<String, String>>; > >-class FormState : public RefCounted<FormState>, public FrameDestructionObserver { >+class FormState : public RefCounted<FormState>, public CanMakeWeakPtr<FormState>, public FrameDestructionObserver { > public: > static Ref<FormState> create(HTMLFormElement&, StringPairVector&& textFieldValues, Document&, FormSubmissionTrigger); > >@@ -50,8 +50,6 @@ public: > Document& sourceDocument() const { return m_sourceDocument; } > FormSubmissionTrigger formSubmissionTrigger() const { return m_formSubmissionTrigger; } > >- auto& weakPtrFactory() const { return m_weakFactory; } >- > private: > FormState(HTMLFormElement&, StringPairVector&& textFieldValues, Document&, FormSubmissionTrigger); > void willDetachPage() override; >@@ -60,7 +58,6 @@ private: > StringPairVector m_textFieldValues; > Ref<Document> m_sourceDocument; > FormSubmissionTrigger m_formSubmissionTrigger; >- WeakPtrFactory<FormState> m_weakFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp >index bcb50d6c85d046b0d24a184af329180e7fdc97f4..e637b3995b17f051afc596864c9350bd67b1dbd4 100644 >--- a/Source/WebCore/loader/LinkLoader.cpp >+++ b/Source/WebCore/loader/LinkLoader.cpp >@@ -215,7 +215,7 @@ void LinkLoader::preconnectIfNeeded(const LinkRelAttribute& relAttribute, const > if (equalIgnoringASCIICase(crossOrigin, "anonymous") && document.securityOrigin().canAccess(SecurityOrigin::create(href))) > storageCredentialsPolicy = StoredCredentialsPolicy::DoNotUse; > ASSERT(document.frame()->loader().networkingContext()); >- platformStrategies()->loaderStrategy()->preconnectTo(document.frame()->loader(), href, storageCredentialsPolicy, [weakDocument = document.createWeakPtr(), href](ResourceError error) { >+ platformStrategies()->loaderStrategy()->preconnectTo(document.frame()->loader(), href, storageCredentialsPolicy, [weakDocument = makeWeakPtr(document), href](ResourceError error) { > if (!weakDocument) > return; > >diff --git a/Source/WebCore/loader/LinkLoader.h b/Source/WebCore/loader/LinkLoader.h >index 7b9bd3934faa09083be434c183d45a767455ccf3..01d1efc315a5b02d0699e9ac45dfd136878f4ab1 100644 >--- a/Source/WebCore/loader/LinkLoader.h >+++ b/Source/WebCore/loader/LinkLoader.h >@@ -46,7 +46,7 @@ class LinkPreloadResourceClient; > > struct LinkRelAttribute; > >-class LinkLoader : private CachedResourceClient { >+class LinkLoader : private CachedResourceClient, public CanMakeWeakPtr<LinkLoader> { > public: > explicit LinkLoader(LinkLoaderClient&); > virtual ~LinkLoader(); >@@ -58,7 +58,6 @@ 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(*this); } > void triggerEvents(const CachedResource&); > void cancelLoad(); > >@@ -71,7 +70,6 @@ private: > LinkLoaderClient& m_client; > CachedResourceHandle<CachedResource> m_cachedLinkResource; > std::unique_ptr<LinkPreloadResourceClient> m_preloadResourceClient; >- WeakPtrFactory<LinkLoader> m_weakPtrFactory; > }; > > } >diff --git a/Source/WebCore/loader/LinkPreloadResourceClients.cpp b/Source/WebCore/loader/LinkPreloadResourceClients.cpp >index 1cd744300f3227dc2897210b7f8bf68d093e7374..ab937736495b28ba7428f1bc3f417b801536cc36 100644 >--- a/Source/WebCore/loader/LinkPreloadResourceClients.cpp >+++ b/Source/WebCore/loader/LinkPreloadResourceClients.cpp >@@ -33,7 +33,7 @@ namespace WebCore { > > LinkPreloadResourceClient::LinkPreloadResourceClient(LinkLoader& loader, CachedResource& resource) > { >- m_loader = loader.createWeakPtr(); >+ m_loader = makeWeakPtr(loader); > m_resource = &resource; > } > >diff --git a/Source/WebCore/loader/MediaResourceLoader.cpp b/Source/WebCore/loader/MediaResourceLoader.cpp >index 3d7c4d4c54d6f42bbb17da1c9dbc75fa4471d647..8077d5a5fe8ac58b6e61deb728fec85b3262dbb5 100644 >--- a/Source/WebCore/loader/MediaResourceLoader.cpp >+++ b/Source/WebCore/loader/MediaResourceLoader.cpp >@@ -43,7 +43,7 @@ namespace WebCore { > MediaResourceLoader::MediaResourceLoader(Document& document, HTMLMediaElement& mediaElement, const String& crossOriginMode) > : ContextDestructionObserver(&document) > , m_document(&document) >- , m_mediaElement(mediaElement.createWeakPtr()) >+ , m_mediaElement(makeWeakPtr(mediaElement)) > , m_crossOriginMode(crossOriginMode) > { > } >diff --git a/Source/WebCore/loader/MediaResourceLoader.h b/Source/WebCore/loader/MediaResourceLoader.h >index 349277e0d9d204029935d79ce44c1365683f94e4..618458a128d426cf12b4b43f4a877066785731ea 100644 >--- a/Source/WebCore/loader/MediaResourceLoader.h >+++ b/Source/WebCore/loader/MediaResourceLoader.h >@@ -44,7 +44,7 @@ class Document; > class HTMLMediaElement; > class MediaResource; > >-class MediaResourceLoader final : public PlatformMediaResourceLoader, public ContextDestructionObserver { >+class MediaResourceLoader final : public PlatformMediaResourceLoader, public CanMakeWeakPtr<MediaResourceLoader>, public ContextDestructionObserver { > public: > WEBCORE_EXPORT MediaResourceLoader(Document&, HTMLMediaElement&, const String& crossOriginMode); > WEBCORE_EXPORT virtual ~MediaResourceLoader(); >@@ -58,8 +58,6 @@ public: > Vector<ResourceResponse> responsesForTesting() const { return m_responsesForTesting; } > void addResponseForTesting(const ResourceResponse&); > >- WeakPtr<const MediaResourceLoader> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } >- > private: > void contextDestroyed() override; > >@@ -67,7 +65,6 @@ private: > WeakPtr<HTMLMediaElement> m_mediaElement; > String m_crossOriginMode; > HashSet<MediaResource*> m_resources; >- WeakPtrFactory<const MediaResourceLoader> m_weakFactory; > Vector<ResourceResponse> m_responsesForTesting; > }; > >diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h >index c7ba747790229d732d233ed4b2d8c47ca444691f..5c48e7cdfde465e2836a257296c9f95f780ee94f 100644 >--- a/Source/WebCore/page/DOMWindow.h >+++ b/Source/WebCore/page/DOMWindow.h >@@ -92,6 +92,7 @@ enum class IncludeTargetOrigin { No, Yes }; > // FIXME: Rename DOMWindow to LocalWindow and AbstractDOMWindow to DOMWindow. > class DOMWindow final > : public AbstractDOMWindow >+ , public CanMakeWeakPtr<DOMWindow> > , public ContextDestructionObserver > , public FrameDestructionObserver > , public Base64Utilities >@@ -335,8 +336,6 @@ public: > void enableSuddenTermination(); > void disableSuddenTermination(); > >- WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > explicit DOMWindow(Document&); > >@@ -393,8 +392,6 @@ private: > enum class PageStatus { None, Shown, Hidden }; > PageStatus m_lastPageStatus { PageStatus::None }; > >- WeakPtrFactory<DOMWindow> m_weakPtrFactory; >- > #if PLATFORM(IOS) > unsigned m_scrollEventListenerCount { 0 }; > #endif >diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp >index a4f63310c7ea0ca3cd18e353ea14373214b7a764..a5bbf90434a5dd939adddd402d48e0357d0512bf 100644 >--- a/Source/WebCore/page/EventHandler.cpp >+++ b/Source/WebCore/page/EventHandler.cpp >@@ -2724,7 +2724,7 @@ static WeakPtr<Widget> widgetForElement(const Element& element) > if (!is<RenderWidget>(target) || !downcast<RenderWidget>(*target).widget()) > return { }; > >- return downcast<RenderWidget>(*target).widget()->createWeakPtr(); >+ return makeWeakPtr(*downcast<RenderWidget>(*target).widget()); > } > > bool EventHandler::completeWidgetWheelEvent(const PlatformWheelEvent& event, const WeakPtr<Widget>& widget, const WeakPtr<ScrollableArea>& scrollableArea, ContainerNode* scrollableContainer) >@@ -3980,7 +3980,7 @@ void EventHandler::updateLastScrollbarUnderMouse(Scrollbar* scrollbar, SetOrClea > // Send mouse entered if we're setting a new scrollbar. > if (scrollbar && setOrClear == SetOrClearLastScrollbar::Set) { > scrollbar->mouseEntered(); >- m_lastScrollbarUnderMouse = scrollbar->createWeakPtr(); >+ m_lastScrollbarUnderMouse = makeWeakPtr(*scrollbar); > } else > m_lastScrollbarUnderMouse = nullptr; > } >diff --git a/Source/WebCore/platform/GenericTaskQueue.cpp b/Source/WebCore/platform/GenericTaskQueue.cpp >index ab08862d3de69da291351d92f63a64a2378cf9d3..7dbba92464650b637fad992c2d0ec6815cadbf12 100644 >--- a/Source/WebCore/platform/GenericTaskQueue.cpp >+++ b/Source/WebCore/platform/GenericTaskQueue.cpp >@@ -38,7 +38,7 @@ TaskDispatcher<Timer>::TaskDispatcher() > void TaskDispatcher<Timer>::postTask(Function<void()>&& function) > { > m_pendingTasks.append(WTFMove(function)); >- pendingDispatchers().append(m_weakPtrFactory.createWeakPtr(*this)); >+ pendingDispatchers().append(makeWeakPtr(*this)); > if (!sharedTimer().isActive()) > sharedTimer().startOneShot(0_s); > } >diff --git a/Source/WebCore/platform/GenericTaskQueue.h b/Source/WebCore/platform/GenericTaskQueue.h >index 02c0ab9c2c7f89f7c86a6710d679bd01bb99e8e5..aaa9450db97db9ce3e4dcec61a4423b36e6ed612 100644 >--- a/Source/WebCore/platform/GenericTaskQueue.h >+++ b/Source/WebCore/platform/GenericTaskQueue.h >@@ -50,7 +50,7 @@ private: > }; > > template<> >-class TaskDispatcher<Timer> { >+class TaskDispatcher<Timer> : public CanMakeWeakPtr<TaskDispatcher<Timer>> { > public: > TaskDispatcher(); > void postTask(WTF::Function<void()>&&); >@@ -62,12 +62,11 @@ private: > > void dispatchOneTask(); > >- WeakPtrFactory<TaskDispatcher> m_weakPtrFactory; > Deque<WTF::Function<void()>> m_pendingTasks; > }; > > template <typename T> >-class GenericTaskQueue { >+class GenericTaskQueue : public CanMakeWeakPtr<GenericTaskQueue<T>> { > public: > GenericTaskQueue() > : m_dispatcher() >@@ -87,8 +86,7 @@ public: > return; > > ++m_pendingTasks; >- auto weakThis = m_weakPtrFactory.createWeakPtr(*this); >- m_dispatcher.postTask([weakThis, task = WTFMove(task)] { >+ m_dispatcher.postTask([weakThis = makeWeakPtr(*this), task = WTFMove(task)] { > if (!weakThis) > return; > ASSERT(weakThis->m_pendingTasks); >@@ -105,13 +103,12 @@ public: > > void cancelAllTasks() > { >- m_weakPtrFactory.revokeAll(); >+ CanMakeWeakPtr<GenericTaskQueue<T>>::weakPtrFactory().revokeAll(); > m_pendingTasks = 0; > } > bool hasPendingTasks() const { return m_pendingTasks; } > > private: >- WeakPtrFactory<GenericTaskQueue> m_weakPtrFactory; > TaskDispatcher<T> m_dispatcher; > unsigned m_pendingTasks { 0 }; > bool m_isClosed { false }; >diff --git a/Source/WebCore/platform/ScrollView.h b/Source/WebCore/platform/ScrollView.h >index 7978102049d6f5ba2b834d03599f27a14572747f..e45ad2bbc3733ce4b93f356361c36b955310ffc3 100644 >--- a/Source/WebCore/platform/ScrollView.h >+++ b/Source/WebCore/platform/ScrollView.h >@@ -74,6 +74,8 @@ public: > > virtual void notifyPageThatContentAreaWillPaint() const; > >+ using Widget::weakPtrFactory; >+ > IntPoint locationOfContents() const; > > // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea. >@@ -372,8 +374,6 @@ public: > void setAllowsUnclampedScrollPositionForTesting(bool allowsUnclampedScrollPosition) { m_allowsUnclampedScrollPosition = allowsUnclampedScrollPosition; } > bool allowsUnclampedScrollPosition() const { return m_allowsUnclampedScrollPosition; } > >- auto& weakPtrFactory() const { return m_weakPtrFactory; } >- > protected: > ScrollView(); > >@@ -460,8 +460,6 @@ private: > > IntPoint m_panScrollIconPoint; > >- WeakPtrFactory<ScrollView> m_weakPtrFactory; >- > bool m_horizontalScrollbarLock { false }; > bool m_verticalScrollbarLock { false }; > >diff --git a/Source/WebCore/platform/ScrollableArea.h b/Source/WebCore/platform/ScrollableArea.h >index b273af058548daadbf2110f1d9dbe8d67516137e..b71939b7bc85b518168bc79f0bd4ca923aa2a222 100644 >--- a/Source/WebCore/platform/ScrollableArea.h >+++ b/Source/WebCore/platform/ScrollableArea.h >@@ -48,7 +48,7 @@ typedef IntPoint ScrollPosition; > // scrollOffset() is the value used by scrollbars (min is 0,0), and should never have negative components. > typedef IntPoint ScrollOffset; > >-class ScrollableArea { >+class ScrollableArea : public CanMakeWeakPtr<ScrollableArea> { > public: > WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1); > WEBCORE_EXPORT void scrollToOffsetWithoutAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped); >@@ -65,8 +65,6 @@ public: > > WEBCORE_EXPORT bool handleWheelEvent(const PlatformWheelEvent&); > >- auto& weakPtrFactory() const { return m_weakPtrFactory; } >- > #if ENABLE(CSS_SCROLL_SNAP) > WEBCORE_EXPORT const Vector<LayoutUnit>* horizontalSnapOffsets() const; > WEBCORE_EXPORT const Vector<LayoutUnit>* verticalSnapOffsets() const; >@@ -338,8 +336,6 @@ protected: > > bool hasLayerForScrollCorner() const; > >- WeakPtrFactory<ScrollableArea> m_weakPtrFactory; >- > private: > WEBCORE_EXPORT virtual IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const; > void scrollPositionChanged(const ScrollPosition&); >diff --git a/Source/WebCore/platform/Scrollbar.h b/Source/WebCore/platform/Scrollbar.h >index 1a86bf3325bcb7317817e67dad1112b4dca02ec4..62f5044a8393be64eebbc6475475e8b2e2d72024 100644 >--- a/Source/WebCore/platform/Scrollbar.h >+++ b/Source/WebCore/platform/Scrollbar.h >@@ -28,7 +28,6 @@ > #include "ScrollTypes.h" > #include "Timer.h" > #include "Widget.h" >-#include <wtf/WeakPtr.h> > > namespace WebCore { > >@@ -133,8 +132,6 @@ public: > > bool supportsUpdateOnSecondaryThread() const; > >- WeakPtr<Scrollbar> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > protected: > Scrollbar(ScrollableArea&, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0, bool isCustomScrollbar = false); > >@@ -183,8 +180,6 @@ protected: > > private: > bool isScrollbar() const override { return true; } >- >- WeakPtrFactory<Scrollbar> m_weakPtrFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/Widget.cpp b/Source/WebCore/platform/Widget.cpp >index 402358bda855df6079c6ca77fa77948e43253b94..c5f78d2dc2f6e332fe2860ab3455a44f38a8a3e6 100644 >--- a/Source/WebCore/platform/Widget.cpp >+++ b/Source/WebCore/platform/Widget.cpp >@@ -46,7 +46,7 @@ void Widget::setParent(ScrollView* view) > ASSERT(!view || !m_parent); > if (!view || !view->isVisible()) > setParentVisible(false); >- m_parent = view ? makeWeakPtr(*view) : nullptr; >+ m_parent = makeWeakPtr(view); > if (view && view->isVisible()) > setParentVisible(true); > } >diff --git a/Source/WebCore/platform/Widget.h b/Source/WebCore/platform/Widget.h >index 4081460cf263efae5edbc5a5e9031c75d593e9cc..f31f245a80bbd70acce62118549cd2d400ac21f3 100644 >--- a/Source/WebCore/platform/Widget.h >+++ b/Source/WebCore/platform/Widget.h >@@ -87,7 +87,7 @@ enum WidgetNotification { WillPaintFlattened, DidPaintFlattened }; > // Scrollbar - Mac, Gtk > // Plugin - Mac, Windows (windowed only), Qt (windowed only, widget is an HWND on windows), Gtk (windowed only) > // >-class Widget : public RefCounted<Widget> { >+class Widget : public RefCounted<Widget>, public CanMakeWeakPtr<Widget> { > public: > WEBCORE_EXPORT explicit Widget(PlatformWidget = nullptr); > WEBCORE_EXPORT virtual ~Widget(); >@@ -187,8 +187,6 @@ public: > WEBCORE_EXPORT virtual IntPoint convertToContainingView(const IntPoint&) const; > WEBCORE_EXPORT virtual IntPoint convertFromContainingView(const IntPoint&) const; > >- WeakPtr<Widget> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > void init(PlatformWidget); // Must be called by all Widget constructors to initialize cross-platform data. > >@@ -210,7 +208,6 @@ private: > #else > RetainPtr<NSView> m_widget; > #endif >- WeakPtrFactory<Widget> m_weakPtrFactory; > bool m_selfVisible; > bool m_parentVisible; > >diff --git a/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp b/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp >index 789869332ec91515edade6a0ed3832cd1c446cce..b9120773dd51015c162784cd2718090768efb7d6 100644 >--- a/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp >+++ b/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp >@@ -38,7 +38,7 @@ > > namespace WebCore { > >-class AudioFileReader { >+class AudioFileReader : public CanMakeWeakPtr<AudioFileReader> { > WTF_MAKE_NONCOPYABLE(AudioFileReader); > public: > AudioFileReader(const char* filePath); >@@ -48,8 +48,6 @@ public: > RefPtr<AudioBus> createBus(float sampleRate, bool mixToMono); > > private: >- WeakPtr<AudioFileReader> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > static void deinterleavePadAddedCallback(AudioFileReader*, GstPad*); > static void deinterleaveReadyCallback(AudioFileReader*); > static void decodebinPadAddedCallback(AudioFileReader*, GstPad*); >@@ -61,7 +59,6 @@ private: > void decodeAudioForBusCreation(); > GstFlowReturn handleSample(GstAppSink*); > >- WeakPtrFactory<AudioFileReader> m_weakPtrFactory; > RunLoop& m_runLoop; > const void* m_data { nullptr }; > size_t m_dataSize { 0 }; >@@ -301,7 +298,7 @@ void AudioFileReader::decodeAudioForBusCreation() > reader.handleMessage(message); > else { > GRefPtr<GstMessage> protectMessage(message); >- auto weakThis = reader.createWeakPtr(); >+ auto weakThis = makeWeakPtr(reader); > reader.m_runLoop.dispatch([weakThis, protectMessage] { > if (weakThis) > weakThis->handleMessage(protectMessage.get()); >diff --git a/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp b/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp >index dbbdc9f0a97f5ba490cf501db33c22453d798784..78cb607bfbde4e44a7d612d1d41eaa0fa7739991 100644 >--- a/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp >+++ b/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.cpp >@@ -125,7 +125,7 @@ AudioHardwareListenerMac::AudioHardwareListenerMac(Client& client) > setHardwareActivity(isAudioHardwareProcessRunning()); > setOutputDeviceSupportsLowPowerMode(currentDeviceSupportsLowPowerBufferSize()); > >- auto weakThis = m_weakFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > m_block = Block_copy(^(UInt32 count, const AudioObjectPropertyAddress properties[]) { > if (weakThis) > weakThis->propertyChanged(count, properties); >diff --git a/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h b/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h >index 6057d3840d13c92435516df52734fca1cf3d6e48..0720ce472eb087ebefe3e168ccefe628f970ee8c 100644 >--- a/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h >+++ b/Source/WebCore/platform/audio/mac/AudioHardwareListenerMac.h >@@ -35,7 +35,7 @@ > > namespace WebCore { > >-class AudioHardwareListenerMac : public AudioHardwareListener { >+class AudioHardwareListenerMac : public AudioHardwareListener, public CanMakeWeakPtr<AudioHardwareListenerMac> { > public: > static WTF::Ref<AudioHardwareListenerMac> create(Client&); > >@@ -49,7 +49,6 @@ private: > void propertyChanged(UInt32, const AudioObjectPropertyAddress[]); > > AudioObjectPropertyListenerBlock m_block; >- WeakPtrFactory<AudioHardwareListenerMac> m_weakFactory; > }; > > } >diff --git a/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp b/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp >index ced546c6d9e9ffbc4e0c9997407bdad76fe33991..b452780d11173000667c28ab3aef8a69d984c646 100644 >--- a/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp >+++ b/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp >@@ -472,7 +472,7 @@ void CDMInstanceClearKey::requestLicense(LicenseType, const AtomicString& initDa > initData = extractKeyidsFromCencInitData(initData.get()); > > callOnMainThread( >- [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), initData = WTFMove(initData), sessionIdValue = s_sessionIdValue]() mutable { >+ [weakThis = makeWeakPtr(*this), callback = WTFMove(callback), initData = WTFMove(initData), sessionIdValue = s_sessionIdValue]() mutable { > if (!weakThis) > return; > >@@ -497,7 +497,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(*this), callback = WTFMove(callback), sessionWasClosed, changedKeys = WTFMove(changedKeys), succeeded] () mutable { >+ [weakThis = makeWeakPtr(*this), callback = WTFMove(callback), sessionWasClosed, changedKeys = WTFMove(changedKeys), succeeded] () mutable { > if (!weakThis) > return; > >@@ -597,7 +597,7 @@ void CDMInstanceClearKey::loadSession(LicenseType, const String& sessionId, cons > auto dispatchCallback = > [this, &callback](std::optional<KeyStatusVector>&& existingKeys, SuccessValue success, SessionLoadFailure loadFailure) { > callOnMainThread( >- [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), existingKeys = WTFMove(existingKeys), success, loadFailure]() mutable { >+ [weakThis = makeWeakPtr(*this), callback = WTFMove(callback), existingKeys = WTFMove(existingKeys), success, loadFailure]() mutable { > if (!weakThis) > return; > >@@ -627,7 +627,7 @@ void CDMInstanceClearKey::loadSession(LicenseType, const String& sessionId, cons > void CDMInstanceClearKey::closeSession(const String&, CloseSessionCallback callback) > { > callOnMainThread( >- [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback)] { >+ [weakThis = makeWeakPtr(*this), callback = WTFMove(callback)] { > if (!weakThis) > return; > >@@ -641,7 +641,7 @@ void CDMInstanceClearKey::removeSessionData(const String& sessionId, LicenseType > auto dispatchCallback = > [this, &callback](KeyStatusVector&& keyStatusVector, std::optional<Ref<SharedBuffer>>&& message, SuccessValue success) { > callOnMainThread( >- [weakThis = m_weakPtrFactory.createWeakPtr(*this), callback = WTFMove(callback), keyStatusVector = WTFMove(keyStatusVector), message = WTFMove(message), success]() mutable { >+ [weakThis = makeWeakPtr(*this), callback = WTFMove(callback), keyStatusVector = WTFMove(keyStatusVector), message = WTFMove(message), success]() mutable { > if (!weakThis) > return; > >diff --git a/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h b/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h >index d98fe07d105d2b1080abd3d53f174dd031f417c9..cd4c8801c19aab0e612352422110af45ea8116f6 100644 >--- a/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h >+++ b/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h >@@ -74,7 +74,7 @@ public: > std::optional<String> sanitizeSessionId(const String&) const override; > }; > >-class CDMInstanceClearKey final : public CDMInstance { >+class CDMInstanceClearKey final : public CDMInstance, public CanMakeWeakPtr<CDMInstanceClearKey> { > public: > CDMInstanceClearKey(); > virtual ~CDMInstanceClearKey(); >@@ -103,9 +103,6 @@ public: > }; > > const Vector<Key> keys() const; >- >-private: >- WeakPtrFactory<CDMInstanceClearKey> m_weakPtrFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/FontCascade.h b/Source/WebCore/platform/graphics/FontCascade.h >index 3529a9569781652e794831e8231a82bfcd455b7c..00590751aaa3d3ad7e6f09e37b109f91c8edfed4 100644 >--- a/Source/WebCore/platform/graphics/FontCascade.h >+++ b/Source/WebCore/platform/graphics/FontCascade.h >@@ -98,7 +98,7 @@ public: > void operator()(TextLayout*) const; > }; > >-class FontCascade { >+class FontCascade : public CanMakeWeakPtr<FontCascade> { > public: > WEBCORE_EXPORT FontCascade(); > WEBCORE_EXPORT FontCascade(FontCascadeDescription&&, float letterSpacing = 0, float wordSpacing = 0); >@@ -199,8 +199,6 @@ public: > > bool primaryFontIsSystemFont() const; > >- WeakPtr<FontCascade> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<FontCascade*>(this)); } >- > std::unique_ptr<DisplayList::DisplayList> displayListForTextRun(GraphicsContext&, const TextRun&, unsigned from = 0, std::optional<unsigned> to = { }, CustomFontNotReadyAction = CustomFontNotReadyAction::DoNotPaintIfFontNotReady) const; > > private: >@@ -313,7 +311,6 @@ private: > > FontCascadeDescription m_fontDescription; > mutable RefPtr<FontCascadeFonts> m_fonts; >- WeakPtrFactory<FontCascade> m_weakPtrFactory; > float m_letterSpacing { 0 }; > float m_wordSpacing { 0 }; > mutable bool m_useBackslashAsYenSymbol { false }; >diff --git a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp >index 1d2870ef768a03598c881998c254dd42557c5df0..ce97351699502044b267a08d5c58690d06540524 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp >+++ b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp >@@ -799,7 +799,7 @@ void MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(Notification > if (delayDispatch && !m_mainThreadCallPending) { > m_mainThreadCallPending = true; > >- callOnMainThread([weakThis = createWeakPtr()] { >+ callOnMainThread([weakThis = makeWeakPtr(*this)] { > if (!weakThis) > return; > >@@ -832,7 +832,7 @@ void MediaPlayerPrivateAVFoundation::dispatchNotification() > } > > if (!m_queuedNotifications.isEmpty() && !m_mainThreadCallPending) { >- callOnMainThread([weakThis = createWeakPtr()] { >+ callOnMainThread([weakThis = makeWeakPtr(*this)] { > if (!weakThis) > return; > >diff --git a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h >index 703f35dfd0d2015c11ef3f0ee52d29b6d9d81a73..3fbcdafac7ae41d1b26b4a95b048e6b7242f0b0b 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h >+++ b/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h >@@ -46,7 +46,7 @@ class InbandMetadataTextTrackPrivateAVF; > class InbandTextTrackPrivateAVF; > class GenericCueData; > >-class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface, public AVFInbandTrackParent >+class MediaPlayerPrivateAVFoundation : public CanMakeWeakPtr<MediaPlayerPrivateAVFoundation>, public MediaPlayerPrivateInterface, public AVFInbandTrackParent > #if !RELEASE_LOG_DISABLED > , private LoggerHelper > #endif >@@ -159,8 +159,6 @@ protected: > explicit MediaPlayerPrivateAVFoundation(MediaPlayer*); > virtual ~MediaPlayerPrivateAVFoundation(); > >- WeakPtr<MediaPlayerPrivateAVFoundation> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > // MediaPlayerPrivatePrivateInterface overrides. > void load(const String& url) override; > #if ENABLE(MEDIA_SOURCE) >@@ -330,8 +328,6 @@ protected: > private: > MediaPlayer* m_player; > >- WeakPtrFactory<MediaPlayerPrivateAVFoundation> m_weakPtrFactory; >- > WTF::Function<void()> m_pendingSeek; > > Deque<Notification> m_queuedNotifications; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h >index bca7b934ab09eea223d86567a0b4b3c03f6023dd..83b9d5023cc18a9e4293ff625af1533ca2fa010f 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h >@@ -42,7 +42,7 @@ OBJC_CLASS WebCoreFPSContentKeySessionDelegate; > > namespace WebCore { > >-class CDMInstanceFairPlayStreamingAVFObjC final : public CDMInstance { >+class CDMInstanceFairPlayStreamingAVFObjC final : public CDMInstance, public CanMakeWeakPtr<CDMInstanceFairPlayStreamingAVFObjC> { > public: > CDMInstanceFairPlayStreamingAVFObjC(); > virtual ~CDMInstanceFairPlayStreamingAVFObjC(); >@@ -82,12 +82,10 @@ public: > AVContentKeySession *contentKeySession() { return m_session.get(); } > > private: >- WeakPtr<CDMInstanceFairPlayStreamingAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > bool isLicenseTypeSupported(LicenseType) const; > > Vector<Ref<SharedBuffer>> keyIDs(); > >- WeakPtrFactory<CDMInstanceFairPlayStreamingAVFObjC> m_weakPtrFactory; > RefPtr<SharedBuffer> m_serverCertificate; > bool m_persistentStateAllowed { true }; > RetainPtr<NSURL> m_storageDirectory; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm >index 03aa6276c0aabca3ad5445432067c1d06d6896f7..46304164e2e1344ef44f5137f9ac7afdfe302757 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm >@@ -455,7 +455,7 @@ void CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest(AVContentKeyRequest > } > > RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData(); >- [m_request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = createWeakPtr()] (NSData *contentKeyRequestData, NSError *error) mutable { >+ [m_request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { > callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { > if (!weakThis || !m_requestLicenseCallback) > return; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h >index 1abe72aaea0cad312518ca4275a9909c2ed9d979..22aafec7b83427b8130a7c043f8f6720834cca47 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h >@@ -39,7 +39,7 @@ namespace WebCore { > > class MediaPlayerPrivateAVFoundationObjC; > >-class CDMSessionAVFoundationObjC : public LegacyCDMSession { >+class CDMSessionAVFoundationObjC : public LegacyCDMSession, public CanMakeWeakPtr<CDMSessionAVFoundationObjC> { > public: > CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent, LegacyCDMSessionClient*); > virtual ~CDMSessionAVFoundationObjC(); >@@ -53,14 +53,11 @@ public: > > void playerDidReceiveError(NSError *); > >- WeakPtr<CDMSessionAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > protected: > WeakPtr<MediaPlayerPrivateAVFoundationObjC> m_parent; > LegacyCDMSessionClient* m_client; > String m_sessionId; > RetainPtr<AVAssetResourceLoadingRequest> m_request; >- WeakPtrFactory<CDMSessionAVFoundationObjC> m_weakPtrFactory; > }; > > } >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm >index d82ef74eeede7346ee5d55ea09ac9701d002b10e..82f4cdc070f53ad07e6b9b5f2c8344f88263b2aa 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm >@@ -50,7 +50,7 @@ SOFT_LINK_CLASS(AVFoundation, AVAssetResourceLoadingRequest) > namespace WebCore { > > CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent, LegacyCDMSessionClient* client) >- : m_parent(parent->createWeakPtr()) >+ : m_parent(makeWeakPtr(*parent)) > , m_client(client) > , m_sessionId(createCanonicalUUIDString()) > { >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h b/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h >index 0b74da4045a7587d140e48d52ff54dd7dc6791bc..e1de72a872b47539ba0593abb9f48cc47562e520 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h >@@ -40,7 +40,7 @@ namespace WebCore { > > class CDMPrivateMediaSourceAVFObjC; > >-class CDMSessionAVStreamSession : public CDMSessionMediaSourceAVFObjC { >+class CDMSessionAVStreamSession : public CDMSessionMediaSourceAVFObjC, public CanMakeWeakPtr<CDMSessionAVStreamSession> { > public: > CDMSessionAVStreamSession(const Vector<int>& protocolVersions, CDMPrivateMediaSourceAVFObjC&, LegacyCDMSessionClient*); > virtual ~CDMSessionAVStreamSession(); >@@ -60,7 +60,6 @@ public: > protected: > RefPtr<Uint8Array> generateKeyReleaseMessage(unsigned short& errorCode, uint32_t& systemCode); > >- WeakPtrFactory<CDMSessionAVStreamSession> m_weakPtrFactory; > RetainPtr<AVStreamSession> m_streamSession; > RefPtr<Uint8Array> m_initData; > RefPtr<Uint8Array> m_certificate; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >index 133cc08dcc56a23ad528681d2e0a57e6fecbe7c7..38325e5b9b73f69802ab3977e1199fdf9364e821 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h >@@ -148,8 +148,6 @@ public: > void attemptToDecryptWithInstance(CDMInstance&) final; > #endif > >- WeakPtr<MediaPlayerPrivateAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > // engine support > static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); >@@ -325,8 +323,6 @@ private: > > AVPlayer *objCAVFoundationAVPlayer() const final { return m_avPlayer.get(); } > >- WeakPtrFactory<MediaPlayerPrivateAVFoundationObjC> m_weakPtrFactory; >- > RetainPtr<AVURLAsset> m_avAsset; > RetainPtr<AVPlayer> m_avPlayer; > RetainPtr<AVPlayerItem> m_avPlayerItem; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >index 48ce77935d912134539e42b7e797c0f8670047e6..ab6024d7f58369914b8c1253b5fc5977df733011 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm >@@ -667,7 +667,7 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoLayer() > if (!m_avPlayer || m_haveBeenAskedToCreateLayer) > return; > >- callOnMainThread([this, weakThis = createWeakPtr()] { >+ callOnMainThread([this, weakThis = makeWeakPtr(*this)] { > if (!weakThis) > return; > >@@ -1097,7 +1097,7 @@ void MediaPlayerPrivateAVFoundationObjC::checkPlayability() > m_haveCheckedPlayability = true; > > INFO_LOG(LOGIDENTIFIER); >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > > [m_avAsset.get() loadValuesAsynchronouslyForKeys:[NSArray arrayWithObjects:@"playable", @"tracks", nil] completionHandler:^{ > callOnMainThread([weakThis] { >@@ -1113,7 +1113,7 @@ void MediaPlayerPrivateAVFoundationObjC::beginLoadingMetadata() > > OSObjectPtr<dispatch_group_t> metadataLoadingGroup = adoptOSObject(dispatch_group_create()); > dispatch_group_enter(metadataLoadingGroup.get()); >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > [m_avAsset.get() loadValuesAsynchronouslyForKeys:assetMetadataKeyNames() completionHandler:^{ > > callOnMainThread([weakThis, metadataLoadingGroup] { >@@ -1337,7 +1337,7 @@ void MediaPlayerPrivateAVFoundationObjC::seekToTime(const MediaTime& time, const > if (CMTimeCompare(cmBefore, kCMTimeZero) < 0) > cmBefore = kCMTimeZero; > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > > [m_avPlayerItem.get() seekToTime:cmTime toleranceBefore:cmBefore toleranceAfter:cmAfter completionHandler:^(BOOL finished) { > callOnMainThread([weakThis, finished] { >@@ -2419,7 +2419,7 @@ std::unique_ptr<LegacyCDMSession> MediaPlayerPrivateAVFoundationObjC::createSess > if (!keySystemIsSupported(keySystem)) > return nullptr; > auto session = std::make_unique<CDMSessionAVFoundationObjC>(this, client); >- m_session = session->createWeakPtr(); >+ m_session = makeWeakPtr(*session); > return WTFMove(session); > } > #endif >@@ -2941,7 +2941,7 @@ void MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget(bool shou > ASSERT(m_playbackTarget->targetType() == MediaPlaybackTarget::Mock); > > setDelayCallbacks(true); >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification([weakThis] { > if (!weakThis) > return; >@@ -3422,7 +3422,7 @@ - (void)observeValueForKeyPath:keyPath ofObject:(id)object change:(NSDictionary > if (!function) > return; > >- auto weakThis = m_callback->createWeakPtr(); >+ auto weakThis = makeWeakPtr(*m_callback); > m_callback->scheduleMainThreadNotification(MediaPlayerPrivateAVFoundation::Notification([weakThis, function = WTFMove(function)]{ > // weakThis and function both refer to the same MediaPlayerPrivateAVFoundationObjC instance. If the WeakPtr has > // been cleared, the underlying object has been destroyed, and it is unsafe to call function(). >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h >index d61e72262b8e3c8e65459a17d9d4758abfbcffa6..6bb1016603c96bea861a2cc15d7bb6e3f0b7121d 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h >@@ -57,7 +57,7 @@ class PixelBufferConformerCV; > class VideoFullscreenLayerManagerObjC; > class VideoTrackPrivateMediaStream; > >-class MediaPlayerPrivateMediaStreamAVFObjC final : public MediaPlayerPrivateInterface, private MediaStreamPrivate::Observer, private MediaStreamTrackPrivate::Observer >+class MediaPlayerPrivateMediaStreamAVFObjC final : public CanMakeWeakPtr<MediaPlayerPrivateMediaStreamAVFObjC>, public MediaPlayerPrivateInterface, private MediaStreamPrivate::Observer, private MediaStreamTrackPrivate::Observer > #if !RELEASE_LOG_DISABLED > , private LoggerHelper > #endif >@@ -78,8 +78,6 @@ public: > MediaPlayer::ReadyState readyState() const override; > void setReadyState(MediaPlayer::ReadyState); > >- WeakPtr<MediaPlayerPrivateMediaStreamAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > void ensureLayers(); > void destroyLayers(); > >@@ -232,7 +230,6 @@ private: > void applicationDidBecomeActive() final; > > MediaPlayer* m_player { nullptr }; >- WeakPtrFactory<MediaPlayerPrivateMediaStreamAVFObjC> m_weakPtrFactory; > RefPtr<MediaStreamPrivate> m_mediaStreamPrivate; > RefPtr<MediaStreamTrackPrivate> m_activeVideoTrack; > RetainPtr<WebAVSampleBufferStatusChangeListener> m_statusChangeListener; >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >index a97c938b2a27c49d41a4fa9d2715d27af5d34287..e1d301dddc6999d6774cb5247127df9a1085b53c 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm >@@ -395,7 +395,7 @@ void MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample(MediaStreamTrackPr > > void MediaPlayerPrivateMediaStreamAVFObjC::requestNotificationWhenReadyForVideoData() > { >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > [m_sampleBufferDisplayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ { > if (!weakThis) > return; >@@ -1133,7 +1133,7 @@ void MediaPlayerPrivateMediaStreamAVFObjC::setShouldBufferData(bool shouldBuffer > void MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask(Function<void ()>&& function) > { > ASSERT(function); >- callOnMainThread([weakThis = createWeakPtr(), function = WTFMove(function)] { >+ callOnMainThread([weakThis = makeWeakPtr(*this), function = WTFMove(function)] { > if (!weakThis) > return; > >diff --git a/Source/WebCore/platform/graphics/cv/TextureCacheCV.h b/Source/WebCore/platform/graphics/cv/TextureCacheCV.h >index 547c79c26f61634c75efeba607b88d87fded12a5..81ab2f924daf26cda22c5e200776c21802023a3b 100644 >--- a/Source/WebCore/platform/graphics/cv/TextureCacheCV.h >+++ b/Source/WebCore/platform/graphics/cv/TextureCacheCV.h >@@ -43,7 +43,7 @@ namespace WebCore { > > class GraphicsContext3D; > >-class TextureCacheCV { >+class TextureCacheCV : public CanMakeWeakPtr<TextureCacheCV> { > public: > static std::unique_ptr<TextureCacheCV> create(GraphicsContext3D&); > >@@ -63,7 +63,6 @@ public: > private: > Ref<GraphicsContext3D> m_context; > RetainPtr<TextureCacheType> m_cache; >- WeakPtrFactory<TextureCacheCV> m_weakPtrFactory; > }; > > } >diff --git a/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm b/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm >index bbb8e75b0138da600199207eb360e2bcccb73d02..cf95929820a00f9746d97c59748ed9f9a9a264a2 100644 >--- a/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm >+++ b/Source/WebCore/platform/graphics/cv/TextureCacheCV.mm >@@ -74,7 +74,7 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelB > #endif > RetainPtr<TextureType> videoTexture = adoptCF(bareVideoTexture); > >- auto weakThis = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > dispatch_async(dispatch_get_main_queue(), [weakThis] { > if (!weakThis) > return; >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >index 7d847f18d766ea6d7fb4586b43435764b9f892ae..6327c2c21f39d4c594f8e508bcae7c67ce4dc4c0 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp >@@ -641,7 +641,7 @@ void MediaPlayerPrivateGStreamer::clearTracks() > #define CREATE_TRACK(type, Type) \ > m_has##Type = true; \ > if (!useMediaSource) {\ >- RefPtr<Type##TrackPrivateGStreamer> track = Type##TrackPrivateGStreamer::create(createWeakPtr(), i, stream); \ >+ RefPtr<Type##TrackPrivateGStreamer> track = Type##TrackPrivateGStreamer::create(makeWeakPtr(*this), i, stream); \ > m_##type##Tracks.add(track->id(), track); \ > m_player->add##Type##Track(*track);\ > if (gst_stream_get_stream_flags(stream.get()) & GST_STREAM_FLAG_SELECT) { \ >@@ -812,7 +812,7 @@ void MediaPlayerPrivateGStreamer::notifyPlayerOfVideo() > } > } > >- RefPtr<VideoTrackPrivateGStreamer> track = VideoTrackPrivateGStreamer::create(createWeakPtr(), i, pad); >+ RefPtr<VideoTrackPrivateGStreamer> track = VideoTrackPrivateGStreamer::create(makeWeakPtr(*this), i, pad); > ASSERT(streamId == track->id()); > m_videoTracks.add(streamId, track); > m_player->addVideoTrack(*track); >@@ -886,7 +886,7 @@ void MediaPlayerPrivateGStreamer::notifyPlayerOfAudio() > } > } > >- RefPtr<AudioTrackPrivateGStreamer> track = AudioTrackPrivateGStreamer::create(createWeakPtr(), i, pad); >+ RefPtr<AudioTrackPrivateGStreamer> track = AudioTrackPrivateGStreamer::create(makeWeakPtr(*this), i, pad); > ASSERT(streamId == track->id()); > m_audioTracks.add(streamId, track); > m_player->addAudioTrack(*track); >@@ -1213,7 +1213,7 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) > case GST_MESSAGE_ELEMENT: > if (gst_is_missing_plugin_message(message)) { > if (gst_install_plugins_supported()) { >- RefPtr<MediaPlayerRequestInstallMissingPluginsCallback> missingPluginCallback = MediaPlayerRequestInstallMissingPluginsCallback::create([weakThis = createWeakPtr()](uint32_t result, MediaPlayerRequestInstallMissingPluginsCallback& missingPluginCallback) { >+ RefPtr<MediaPlayerRequestInstallMissingPluginsCallback> missingPluginCallback = MediaPlayerRequestInstallMissingPluginsCallback::create([weakThis = makeWeakPtr(*this)](uint32_t result, MediaPlayerRequestInstallMissingPluginsCallback& missingPluginCallback) { > if (!weakThis) { > GST_INFO("got missing pluging installation callback in destroyed player with result %u", result); > return; >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >index 1ae4a54bae0add3ffafc10a24c401549583e8d56..927ac380a92a4b4099efb6c4f7a9b36e22ed5a28 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h >@@ -60,13 +60,11 @@ class VideoTrackPrivateGStreamer; > class MediaSourcePrivateClient; > #endif > >-class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateGStreamerBase { >+class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateGStreamerBase, public CanMakeWeakPtr<MediaPlayerPrivateGStreamer> { > public: > explicit MediaPlayerPrivateGStreamer(MediaPlayer*); > virtual ~MediaPlayerPrivateGStreamer(); > >- WeakPtr<MediaPlayerPrivateGStreamer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > static void registerMediaEngine(MediaEngineRegistrar); > void handleMessage(GstMessage*); > void handlePluginInstallerResult(GstInstallPluginsReturn); >@@ -236,7 +234,6 @@ protected: > #endif > > private: >- WeakPtrFactory<MediaPlayerPrivateGStreamer> m_weakPtrFactory; > > #if ENABLE(VIDEO_TRACK) > GRefPtr<GstElement> m_textAppSink; >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >index 2eb441d2753ae2d5f5a88a952b4be6b5b7f0c5f7..c172bcaf2476a79616721807f3640cf7e4c82d14 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >@@ -384,7 +384,7 @@ bool MediaPlayerPrivateGStreamerBase::handleSyncMessage(GstMessage* message) > if (concatenatedInitDataChunksNumber > 1) > eventKeySystemIdString = emptyString(); > >- RunLoop::main().dispatch([weakThis = m_weakPtrFactory.createWeakPtr(*this), eventKeySystemIdString, initData = WTFMove(concatenatedInitDataChunks)] { >+ RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), eventKeySystemIdString, initData = WTFMove(concatenatedInitDataChunks)] { > if (!weakThis) > return; > >@@ -1243,7 +1243,7 @@ void MediaPlayerPrivateGStreamerBase::initializationDataEncountered(GstEvent* ev > gst_buffer_unmap(data, &mapInfo); > > String eventKeySystemUUIDString = eventKeySystemUUID; >- RunLoop::main().dispatch([weakThis = m_weakPtrFactory.createWeakPtr(*this), eventKeySystemUUID = eventKeySystemUUIDString, initData] { >+ RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), eventKeySystemUUID = eventKeySystemUUIDString, initData] { > if (!weakThis) > return; > >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >index ce5d825b1fd9fce5bb07855433c83f97be0b1f7e..7862a8cd5c235163e821706ee82c77e1fa47611b 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >@@ -61,7 +61,7 @@ class TextureMapperPlatformLayerProxy; > > void registerWebKitGStreamerElements(); > >-class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface >+class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface, public CanMakeWeakPtr<MediaPlayerPrivateGStreamerBase> > #if USE(TEXTURE_MAPPER_GL) > , public PlatformLayer > #endif >@@ -217,7 +217,6 @@ protected: > #endif > }; > >- WeakPtrFactory<MediaPlayerPrivateGStreamerBase> m_weakPtrFactory; > Ref<MainThreadNotifier<MainThreadNotification>> m_notifier; > MediaPlayer* m_player; > GRefPtr<GstElement> m_pipeline; >diff --git a/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp b/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp >index e213d2de41cd21d92197fd43d51983dbc16bce33..fd186af9909ba0ecbab12d2f8e44c9bda727c0d2 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp >@@ -1013,11 +1013,11 @@ void AppendPipeline::connectDemuxerSrcPadToAppsink(GstPad* demuxerSrcPad) > switch (m_streamType) { > case WebCore::MediaSourceStreamTypeGStreamer::Audio: > if (m_playerPrivate) >- m_track = WebCore::AudioTrackPrivateGStreamer::create(m_playerPrivate->createWeakPtr(), id(), sinkSinkPad.get()); >+ m_track = WebCore::AudioTrackPrivateGStreamer::create(makeWeakPtr(*m_playerPrivate), id(), sinkSinkPad.get()); > break; > case WebCore::MediaSourceStreamTypeGStreamer::Video: > if (m_playerPrivate) >- m_track = WebCore::VideoTrackPrivateGStreamer::create(m_playerPrivate->createWeakPtr(), id(), sinkSinkPad.get()); >+ m_track = WebCore::VideoTrackPrivateGStreamer::create(makeWeakPtr(*m_playerPrivate), id(), sinkSinkPad.get()); > break; > case WebCore::MediaSourceStreamTypeGStreamer::Text: > m_track = WebCore::InbandTextTrackPrivateGStreamer::create(id(), sinkSinkPad.get()); >diff --git a/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp b/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp >index d93d2b13e3ad9355eae04f9dbaeff5deef92c90c..beb6c0472522d5d6a0ada5661d2fcd77f9308093 100644 >--- a/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp >+++ b/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.cpp >@@ -89,7 +89,7 @@ void DisplayRefreshMonitorMac::displayLinkFired() > > setIsPreviousFrameDone(false); > >- RunLoop::main().dispatch([weakPtr = m_weakFactory.createWeakPtr(*this)] { >+ RunLoop::main().dispatch([weakPtr = makeWeakPtr(*this)] { > if (auto* monitor = weakPtr.get()) > handleDisplayRefreshedNotificationOnMainThread(monitor); > }); >diff --git a/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h b/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h >index 3f7ccdf28d73c6e5dc008c0a51e0051427dfb3cf..a454577d56ed1597ec2c9c57a808d319e78e6242 100644 >--- a/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h >+++ b/Source/WebCore/platform/graphics/mac/DisplayRefreshMonitorMac.h >@@ -34,7 +34,7 @@ typedef struct __CVDisplayLink *CVDisplayLinkRef; > > namespace WebCore { > >-class DisplayRefreshMonitorMac : public DisplayRefreshMonitor { >+class DisplayRefreshMonitorMac : public DisplayRefreshMonitor, public CanMakeWeakPtr<DisplayRefreshMonitorMac> { > public: > static Ref<DisplayRefreshMonitorMac> create(PlatformDisplayID displayID) > { >@@ -49,7 +49,6 @@ public: > private: > explicit DisplayRefreshMonitorMac(PlatformDisplayID); > >- WeakPtrFactory<DisplayRefreshMonitorMac> m_weakFactory; > CVDisplayLinkRef m_displayLink { nullptr }; > }; > >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp >index 25b6ca43ddc1fcba9d54b173100bda44f421efdc..1dc83760dae2de803dd65b9425b9dc9ffd416c68 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp >@@ -495,8 +495,8 @@ void TextureMapperLayer::removeAllChildren() > void TextureMapperLayer::setMaskLayer(TextureMapperLayer* maskLayer) > { > if (maskLayer) { >- maskLayer->m_effectTarget = createWeakPtr(); >- m_state.maskLayer = maskLayer->createWeakPtr(); >+ maskLayer->m_effectTarget = makeWeakPtr(*this); >+ m_state.maskLayer = makeWeakPtr(*maskLayer); > } else > m_state.maskLayer = nullptr; > } >@@ -504,8 +504,8 @@ void TextureMapperLayer::setMaskLayer(TextureMapperLayer* maskLayer) > void TextureMapperLayer::setReplicaLayer(TextureMapperLayer* replicaLayer) > { > if (replicaLayer) { >- replicaLayer->m_effectTarget = createWeakPtr(); >- m_state.replicaLayer = replicaLayer->createWeakPtr(); >+ replicaLayer->m_effectTarget = makeWeakPtr(*this); >+ m_state.replicaLayer = makeWeakPtr(*replicaLayer); > } else > m_state.replicaLayer = nullptr; > } >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h >index ac10794693188f52865db8de27d42830b5a56ed2..33fc9aebb3f7ce664ff77b000f3c46b10aae5dd0 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h >@@ -34,13 +34,12 @@ class Region; > class TextureMapperPaintOptions; > class TextureMapperPlatformLayer; > >-class WEBCORE_EXPORT TextureMapperLayer { >+class WEBCORE_EXPORT TextureMapperLayer : public CanMakeWeakPtr<TextureMapperLayer> { > WTF_MAKE_NONCOPYABLE(TextureMapperLayer); > WTF_MAKE_FAST_ALLOCATED; > public: > TextureMapperLayer(); > virtual ~TextureMapperLayer(); >- WeakPtr<TextureMapperLayer> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } > > void setID(uint32_t id) { m_id = id; } > uint32_t id() { return m_id; } >@@ -141,7 +140,6 @@ private: > return FloatRect(FloatPoint::zero(), m_state.size); > } > >- WeakPtrFactory<TextureMapperLayer> m_weakFactory; > Vector<TextureMapperLayer*> m_children; > TextureMapperLayer* m_parent { nullptr }; > WeakPtr<TextureMapperLayer> m_effectTarget; >diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp >index 359ee11d5c0409e3211178e659b22f2183557e4a..3840fddca3dff6cd0fb830080d8539496a522157 100644 >--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp >+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp >@@ -499,7 +499,7 @@ bool MediaPlayerPrivateMediaFoundation::endCreatedMediaSource(IMFAsyncResult* as > hr = asyncResult->GetStatus(); > m_loadingProgress = SUCCEEDED(hr); > >- callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] { >+ callOnMainThread([weakPtr = makeWeakPtr(*this)] { > if (!weakPtr) > return; > weakPtr->onCreatedMediaSource(); >@@ -528,7 +528,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult) > > switch (mediaEventType) { > case MESessionTopologySet: { >- callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] { >+ callOnMainThread([weakPtr = makeWeakPtr(*this)] { > if (!weakPtr) > return; > weakPtr->onTopologySet(); >@@ -537,7 +537,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult) > } > > case MESessionStarted: { >- callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] { >+ callOnMainThread([weakPtr = makeWeakPtr(*this)] { > if (!weakPtr) > return; > weakPtr->onSessionStarted(); >@@ -546,7 +546,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult) > } > > case MEBufferingStarted: { >- callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] { >+ callOnMainThread([weakPtr = makeWeakPtr(*this)] { > if (!weakPtr) > return; > weakPtr->onBufferingStarted(); >@@ -555,7 +555,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult) > } > > case MEBufferingStopped: { >- callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] { >+ callOnMainThread([weakPtr = makeWeakPtr(*this)] { > if (!weakPtr) > return; > weakPtr->onBufferingStopped(); >@@ -564,7 +564,7 @@ bool MediaPlayerPrivateMediaFoundation::endGetEvent(IMFAsyncResult* asyncResult) > } > > case MESessionEnded: { >- callOnMainThread([weakPtr = m_weakPtrFactory.createWeakPtr(*this)] { >+ callOnMainThread([weakPtr = makeWeakPtr(*this)] { > if (!weakPtr) > return; > weakPtr->onSessionEnded(); >@@ -1723,7 +1723,7 @@ HRESULT MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNot > > // Invalidate the video area > if (m_mediaPlayer) { >- callOnMainThread([weakPtr = m_mediaPlayer->m_weakPtrFactory.createWeakPtr(*m_mediaPlayer)] { >+ callOnMainThread([weakPtr = m_mediaPlayer->makeWeakPtr(*m_mediaPlayer)] { > if (weakPtr) > weakPtr->invalidateFrameView(); > }); >diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h >index c672c2298b4629aaa1aae451211b58639e0533a3..fccee1c125cf8800676c63c92af74afe5a4bac8c 100644 >--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h >+++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h >@@ -46,7 +46,7 @@ > > namespace WebCore { > >-class MediaPlayerPrivateMediaFoundation : public MediaPlayerPrivateInterface { >+class MediaPlayerPrivateMediaFoundation : public MediaPlayerPrivateInterface, public CanMakeWeakPtr<MediaPlayerPrivateMediaFoundation> { > public: > explicit MediaPlayerPrivateMediaFoundation(MediaPlayer*); > ~MediaPlayerPrivateMediaFoundation(); >@@ -124,7 +124,6 @@ private: > FloatSize m_cachedNaturalSize; > mutable Lock m_cachedNaturalSizeLock; > >- WeakPtrFactory<MediaPlayerPrivateMediaFoundation> m_weakPtrFactory; > COMPtr<IMFMediaSession> m_mediaSession; > COMPtr<IMFSourceResolver> m_sourceResolver; > COMPtr<IMFMediaSource> m_mediaSource; >diff --git a/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h b/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h >index d507c31c9ec11d873eb85036fb13e60b1f08a0d6..f8b141b4dac317dd88b5af80ffcc1c9b18048489 100644 >--- a/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h >+++ b/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h >@@ -38,16 +38,14 @@ typedef void *id; > > namespace WebCore { > >-class RemoteCommandListenerIOS : public RemoteCommandListener { >+class RemoteCommandListenerIOS : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerIOS> { > public: > RemoteCommandListenerIOS(RemoteCommandListenerClient&); > virtual ~RemoteCommandListenerIOS(); > > protected: >- WeakPtr<RemoteCommandListenerIOS> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > void updateSupportedCommands() override; > >- WeakPtrFactory<RemoteCommandListenerIOS> m_weakPtrFactory; > RetainPtr<id> m_playTarget; > RetainPtr<id> m_pauseTarget; > RetainPtr<id> m_togglePlayPauseTarget; >diff --git a/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm b/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm >index 35ef1cf24fc71c58bb5b7cdfca58f5a03bf8ee6c..9ae7739c52ded53b759a31f146428b656db6807d 100644 >--- a/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm >+++ b/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm >@@ -52,7 +52,7 @@ RemoteCommandListenerIOS::RemoteCommandListenerIOS(RemoteCommandListenerClient& > : RemoteCommandListener(client) > { > MPRemoteCommandCenter *center = [getMPRemoteCommandCenterClass() sharedCommandCenter]; >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > > m_pauseTarget = [[center pauseCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) { > callOnMainThread([weakThis] { >diff --git a/Source/WebCore/platform/mac/RemoteCommandListenerMac.h b/Source/WebCore/platform/mac/RemoteCommandListenerMac.h >index b781e6ad4a1c2f84e9416c5e4b1631ddf3ac256d..94a42e19171b2dcb9fe9b90f1d58c23c9f78a23b 100644 >--- a/Source/WebCore/platform/mac/RemoteCommandListenerMac.h >+++ b/Source/WebCore/platform/mac/RemoteCommandListenerMac.h >@@ -33,17 +33,14 @@ > > namespace WebCore { > >-class RemoteCommandListenerMac : public RemoteCommandListener { >+class RemoteCommandListenerMac : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerMac> { > public: > RemoteCommandListenerMac(RemoteCommandListenerClient&); > virtual ~RemoteCommandListenerMac(); > > protected: >- WeakPtr<RemoteCommandListenerMac> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > void updateSupportedCommands() override; > >- WeakPtrFactory<RemoteCommandListenerMac> m_weakPtrFactory; > void* m_commandHandler { nullptr }; > }; > >diff --git a/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm b/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm >index 3d7472222c23e0b10a927cad18b3c6f4b15e9366..05cc08957e1d50124dd632e2a4c8921298969611 100644 >--- a/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm >+++ b/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm >@@ -84,7 +84,7 @@ RemoteCommandListenerMac::RemoteCommandListenerMac(RemoteCommandListenerClient& > > updateSupportedCommands(); > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > m_commandHandler = MRMediaRemoteAddAsyncCommandHandlerBlock(^(MRMediaRemoteCommand command, CFDictionaryRef options, void(^completion)(CFArrayRef)) { > > LOG(Media, "RemoteCommandListenerMac::RemoteCommandListenerMac - received command %u", command); >diff --git a/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp b/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp >index 42647705b82df3df6e15d7c056e28d6450b7d754..fcb423f3c8c15def8390ddd37f5ee0e54d2aa879 100644 >--- a/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp >+++ b/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp >@@ -294,7 +294,7 @@ void MediaStreamPrivate::trackEnded(MediaStreamTrackPrivate&) > void MediaStreamPrivate::scheduleDeferredTask(Function<void ()>&& function) > { > ASSERT(function); >- callOnMainThread([weakThis = createWeakPtr(), function = WTFMove(function)] { >+ callOnMainThread([weakThis = makeWeakPtr(*this), function = WTFMove(function)] { > if (!weakThis) > return; > >diff --git a/Source/WebCore/platform/mediastream/MediaStreamPrivate.h b/Source/WebCore/platform/mediastream/MediaStreamPrivate.h >index c984deb91f784f6b80434d783488292747f497df..357fd306d95ea143b4604b690481bf64093f1196 100644 >--- a/Source/WebCore/platform/mediastream/MediaStreamPrivate.h >+++ b/Source/WebCore/platform/mediastream/MediaStreamPrivate.h >@@ -53,7 +53,7 @@ namespace WebCore { > class MediaStream; > class OrientationNotifier; > >-class MediaStreamPrivate : public MediaStreamTrackPrivate::Observer, public RefCounted<MediaStreamPrivate> { >+class MediaStreamPrivate : public MediaStreamTrackPrivate::Observer, public RefCounted<MediaStreamPrivate>, public CanMakeWeakPtr<MediaStreamPrivate> { > public: > class Observer { > public: >@@ -102,8 +102,6 @@ public: > > FloatSize intrinsicSize() const; > >- WeakPtr<MediaStreamPrivate> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > void monitorOrientation(OrientationNotifier&); > > private: >@@ -121,7 +119,6 @@ private: > > void scheduleDeferredTask(Function<void ()>&&); > >- WeakPtrFactory<MediaStreamPrivate> m_weakPtrFactory; > Vector<Observer*> m_observers; > String m_id; > MediaStreamTrackPrivate* m_activeVideoTrack { nullptr }; >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >index 6c089d02346aa390120d76b9afc115d7afecd6f0..7ba40fcd7a1372d6287bc384bf71a3bee24da72c 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >@@ -913,7 +913,7 @@ void RealtimeMediaSource::setEchoCancellation(bool echoCancellation) > void RealtimeMediaSource::scheduleDeferredTask(WTF::Function<void()>&& function) > { > ASSERT(function); >- callOnMainThread([weakThis = createWeakPtr(), function = WTFMove(function)] { >+ callOnMainThread([weakThis = makeWeakPtr(*this), function = WTFMove(function)] { > if (!weakThis) > return; > >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >index 9b451205e5b93a51ee1adc24e5c00eb38e5358b5..39b510b53047f10bfc04cf516fe40afd8f51a789 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >@@ -62,7 +62,7 @@ class RealtimeMediaSourceSettings; > > struct CaptureSourceOrError; > >-class WEBCORE_EXPORT RealtimeMediaSource : public ThreadSafeRefCounted<RealtimeMediaSource> { >+class WEBCORE_EXPORT RealtimeMediaSource : public ThreadSafeRefCounted<RealtimeMediaSource>, public CanMakeWeakPtr<RealtimeMediaSource> { > public: > class Observer { > public: >@@ -249,15 +249,12 @@ protected: > void videoSampleAvailable(MediaSample&); > void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t); > >- WeakPtr<RealtimeMediaSource> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > virtual void startProducingData() { } > virtual void stopProducingData() { } > > bool m_muted { false }; > >- WeakPtrFactory<RealtimeMediaSource> m_weakPtrFactory; > String m_id; > String m_persistentID; > Type m_type; >diff --git a/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h b/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h >index 07bc3f830a0c65cf77c5b9fde567a5560e35b022..3db270fea441ec5736fd7f907327ccb3ed945137 100644 >--- a/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h >+++ b/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h >@@ -100,7 +100,6 @@ private: > RetainPtr<CGDisplayStreamRef> m_displayStream; > RetainPtr<CFMutableDictionaryRef> m_bufferAttributes; > CGDisplayStreamFrameAvailableHandler m_frameAvailableBlock; >- WeakPtrFactory<ScreenDisplayCaptureSourceMac> m_weakFactory; > MediaTime m_presentationTimeStamp; > MediaTime m_frameDuration; > >diff --git a/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm b/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm >index 78aa012f5da96533715a7c6a092e6b580e01bf0c..cf494b87b027d7e6f9d4a0909f1262615c3ca211 100644 >--- a/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm >+++ b/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm >@@ -167,7 +167,7 @@ bool ScreenDisplayCaptureSourceMac::createDisplayStream() > }; > auto streamOptions = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); > >- auto weakThis = m_weakFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > m_frameAvailableBlock = Block_copy(^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef) { > if (!weakThis) > return; >diff --git a/Source/WebCore/platform/vr/VRPlatformDisplay.h b/Source/WebCore/platform/vr/VRPlatformDisplay.h >index 762325cbc44af2f117f086cb901bac0cd09e7238..1a08eb28ff24a35a2191eafb929b7a0423b27cad 100644 >--- a/Source/WebCore/platform/vr/VRPlatformDisplay.h >+++ b/Source/WebCore/platform/vr/VRPlatformDisplay.h >@@ -157,15 +157,11 @@ struct VRPlatformTrackingInfo { > double timestamp { 0 }; > }; > >-class VRPlatformDisplay { >+class VRPlatformDisplay : public CanMakeWeakPtr<VRPlatformDisplay> { > public: > virtual VRPlatformDisplayInfo getDisplayInfo() = 0; > virtual VRPlatformTrackingInfo getTrackingInfo() = 0; > virtual ~VRPlatformDisplay() = default; >- >- WeakPtr<VRPlatformDisplay> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >-private: >- WeakPtrFactory<VRPlatformDisplay> m_weakPtrFactory; > }; > > }; // namespace WebCore >diff --git a/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp b/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp >index 99a8f1d1716b1a8481c56d38daf7df8f01fe8c33..d1dc673686f651e3e03291b7c02c31b0c169bbc2 100644 >--- a/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp >+++ b/Source/WebCore/platform/vr/openvr/VRPlatformManagerOpenVR.cpp >@@ -79,7 +79,7 @@ Vector<WeakPtr<VRPlatformDisplay>> VRPlatformManagerOpenVR::getVRDisplays() > Vector<WeakPtr<VRPlatformDisplay>> displays; > if (!m_display) > m_display = std::make_unique<VRPlatformDisplayOpenVR>(m_system, chaperone, compositor); >- displays.append(m_display->createWeakPtr()); >+ displays.append(makeWeakPtr(*m_display)); > return displays; > } > >diff --git a/Source/WebCore/rendering/FloatingObjects.h b/Source/WebCore/rendering/FloatingObjects.h >index 6661928454f00dc3f08ae22ae075ecbdd8cc8f5c..11e68a7a7b9f2c28f900d3c0e0b3eba7dec27217 100644 >--- a/Source/WebCore/rendering/FloatingObjects.h >+++ b/Source/WebCore/rendering/FloatingObjects.h >@@ -85,7 +85,7 @@ public: > // FIXME: Callers of these methods are dangerous and should be whitelisted explicitly or removed. > RootInlineBox* originatingLine() const { return m_originatingLine.get(); } > void clearOriginatingLine() { m_originatingLine = nullptr; } >- void setOriginatingLine(RootInlineBox& line) { m_originatingLine = line.createWeakPtr(); } >+ void setOriginatingLine(RootInlineBox& line) { m_originatingLine = makeWeakPtr(line); } > > LayoutSize locationOffsetOfBorderBox() const > { >diff --git a/Source/WebCore/rendering/RenderObject.h b/Source/WebCore/rendering/RenderObject.h >index 83abfb87989075e3c7f0d97f37ecc3aa738a8a19..ccd686e51cbda3708ba966615c3d13ecfe99e77c 100644 >--- a/Source/WebCore/rendering/RenderObject.h >+++ b/Source/WebCore/rendering/RenderObject.h >@@ -102,7 +102,7 @@ struct AnnotatedRegionValue { > #endif > > // Base class for all rendering tree objects. >-class RenderObject : public CachedImageClient { >+class RenderObject : public CachedImageClient, public CanMakeWeakPtr<RenderObject> { > WTF_MAKE_ISO_ALLOCATED(RenderObject); > friend class RenderBlock; > friend class RenderBlockFlow; >@@ -114,8 +114,6 @@ public: > explicit RenderObject(Node&); > virtual ~RenderObject(); > >- auto& weakPtrFactory() const { return m_weakFactory; } >- > RenderTheme& theme() const; > > virtual const char* renderName() const = 0; >@@ -838,8 +836,6 @@ private: > RenderObject* m_previous; > RenderObject* m_next; > >- WeakPtrFactory<RenderObject> m_weakFactory; >- > #ifndef NDEBUG > bool m_hasAXObject : 1; > bool m_setNeedsLayoutForbidden : 1; >diff --git a/Source/WebCore/rendering/RootInlineBox.cpp b/Source/WebCore/rendering/RootInlineBox.cpp >index 08690b9c26d5421472222238741c26c6fa47f821..c8c0e5439f232e5215421c820a605683c4064c20 100644 >--- a/Source/WebCore/rendering/RootInlineBox.cpp >+++ b/Source/WebCore/rendering/RootInlineBox.cpp >@@ -45,9 +45,9 @@ namespace WebCore { > > WTF_MAKE_ISO_ALLOCATED_IMPL(RootInlineBox); > >-struct SameSizeAsRootInlineBox : public InlineFlowBox { >+struct SameSizeAsRootInlineBox : public InlineFlowBox, public CanMakeWeakPtr<RootInlineBox> { > unsigned variables[7]; >- void* pointers[4]; >+ void* pointers[3]; > }; > > COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInlineBox_should_stay_small); >diff --git a/Source/WebCore/rendering/RootInlineBox.h b/Source/WebCore/rendering/RootInlineBox.h >index 4eec009791a0501d2af64d923171c98cf17a9ca4..dd9594ffbcfbc0f62b9ae71a7542a58077d5c211 100644 >--- a/Source/WebCore/rendering/RootInlineBox.h >+++ b/Source/WebCore/rendering/RootInlineBox.h >@@ -36,12 +36,11 @@ class RenderFragmentContainer; > struct BidiStatus; > struct GapRects; > >-class RootInlineBox : public InlineFlowBox { >+class RootInlineBox : public InlineFlowBox, public CanMakeWeakPtr<RootInlineBox> { > WTF_MAKE_ISO_ALLOCATED(RootInlineBox); > public: > explicit RootInlineBox(RenderBlockFlow&); > virtual ~RootInlineBox(); >- WeakPtr<RootInlineBox> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } > > RenderBlockFlow& blockFlow() const; > >@@ -232,7 +231,6 @@ private: > // Floats hanging off the line are pushed into this vector during layout. It is only > // good for as long as the line has not been marked dirty. > std::unique_ptr<CleanLineFloatList> m_floats; >- WeakPtrFactory<RootInlineBox> m_weakPtrFactory; > }; > > inline RootInlineBox* RootInlineBox::nextRootBox() const >diff --git a/Source/WebCore/svg/SVGPathElement.h b/Source/WebCore/svg/SVGPathElement.h >index bcdf148e5e8aec20b2e54c68a7ef820be305b332..1e4ec8f6385057723c338f5e098544a366b90e52 100644 >--- a/Source/WebCore/svg/SVGPathElement.h >+++ b/Source/WebCore/svg/SVGPathElement.h >@@ -53,7 +53,7 @@ class SVGPathSegCurvetoQuadraticSmoothRel; > class SVGPathSegList; > class SVGPoint; > >-class SVGPathElement final : public SVGGeometryElement, public SVGExternalResourcesRequired { >+class SVGPathElement final : public SVGGeometryElement, public SVGExternalResourcesRequired, public CanMakeWeakPtr<SVGPathElement> { > WTF_MAKE_ISO_ALLOCATED(SVGPathElement); > public: > static Ref<SVGPathElement> create(const QualifiedName&, Document&); >@@ -99,8 +99,6 @@ public: > > bool isAnimValObserved() const { return m_isAnimValObserved; } > >- WeakPtr<SVGPathElement> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<SVGPathElement*>(this)); } >- > void animatedPropertyWillBeDeleted(); > > size_t approximateMemoryCost() const final; >@@ -135,7 +133,6 @@ private: > SVGPathByteStream m_pathByteStream; > mutable std::optional<Path> m_cachedPath; > mutable SVGSynchronizableAnimatedProperty<SVGPathSegListValues> m_pathSegList; >- WeakPtrFactory<SVGPathElement> m_weakPtrFactory; > bool m_isAnimValObserved; > }; > >diff --git a/Source/WebCore/svg/SVGPathSegWithContext.h b/Source/WebCore/svg/SVGPathSegWithContext.h >index 60f392582c1b569f85b28f11cb600219f6de6e73..4e395b9e2fa839fa93fd837b81a0ab06210d3a60 100644 >--- a/Source/WebCore/svg/SVGPathSegWithContext.h >+++ b/Source/WebCore/svg/SVGPathSegWithContext.h >@@ -27,7 +27,7 @@ class SVGPathSegWithContext : public SVGPathSeg { > public: > SVGPathSegWithContext(const SVGPathElement& element, SVGPathSegRole role) > : m_role(role) >- , m_element(element.createWeakPtr()) >+ , m_element(makeWeakPtr(const_cast<SVGPathElement&>(element))) > { > } > >@@ -55,7 +55,7 @@ public: > void setContextAndRole(SVGPathElement* element, SVGPathSegRole role) > { > m_role = role; >- m_element = element ? element->createWeakPtr() : WeakPtr<SVGPathElement>(); >+ m_element = makeWeakPtr(element); > } > > protected: >diff --git a/Source/WebCore/svg/SVGTransformList.h b/Source/WebCore/svg/SVGTransformList.h >index 3b3433344e9ccff25e4961d1fbcf0be1d0a1e090..c872fca5276206c9cb42decc017c5a7c0f915447 100644 >--- a/Source/WebCore/svg/SVGTransformList.h >+++ b/Source/WebCore/svg/SVGTransformList.h >@@ -61,7 +61,7 @@ public: > detachListWrappers(0); > > RefPtr<SVGTransform> wrapper = m_values->consolidate(); >- m_wrappers->append(wrapper->createWeakPtr()); >+ m_wrappers->append(makeWeakPtr(*wrapper)); > > ASSERT(m_values->size() == m_wrappers->size()); > return WTFMove(wrapper); >diff --git a/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h b/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h >index 60c4ba06e12278cd367bd3a8e635a010f04ae53b..4298c6eb15cf8f6130e32cf487b2bf3e6855da48 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h >@@ -51,7 +51,7 @@ public: > return *static_cast<ListPropertyTearOff*>(m_baseVal.get()); > > auto property = ListPropertyTearOff::create(*this, BaseValRole, m_values, m_wrappers); >- m_baseVal = property->createWeakPtr(); >+ m_baseVal = makeWeakPtr(property.get()); > return property; > } > >@@ -61,7 +61,7 @@ public: > return *static_cast<ListPropertyTearOff*>(m_animVal.get()); > > auto property = ListPropertyTearOff::create(*this, AnimValRole, m_values, m_wrappers); >- m_animVal = property->createWeakPtr(); >+ m_animVal = makeWeakPtr(property.get()); > return property; > } > >diff --git a/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h b/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h >index 2e3d1f8305e6ab4cd6ca9a7065703fed4230a720..6732f9af24c1ab5d2f7d7d9f3c16a768f9eafd27 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h >@@ -43,7 +43,7 @@ public: > return *static_cast<ListPropertyTearOff*>(m_baseVal.get()); > > auto property = SVGPathSegList::create(*this, BaseValRole, PathSegUnalteredRole, m_values, m_wrappers); >- m_baseVal = property->createWeakPtr(); >+ m_baseVal = makeWeakPtr(property.get()); > return property; > } > >@@ -53,7 +53,7 @@ public: > return *static_cast<ListPropertyTearOff*>(m_animVal.get()); > > auto property = SVGPathSegList::create(*this, AnimValRole, PathSegUnalteredRole, m_values, m_wrappers); >- m_animVal = property->createWeakPtr(); >+ m_animVal = makeWeakPtr(property.get()); > return property; > } > >diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h >index ee5f06eb292fcc61acf62a9fbfeeceab2b396ca4..20ce5e58315a3bcb13fff8996b51d68b0afe25c7 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h >@@ -44,7 +44,7 @@ public: > return *static_cast<PropertyTearOff*>(m_baseVal.get()); > > auto property = PropertyTearOff::create(*this, BaseValRole, m_property); >- m_baseVal = property->createWeakPtr(); >+ m_baseVal = makeWeakPtr(property.get()); > return property; > } > >@@ -54,7 +54,7 @@ public: > return *static_cast<PropertyTearOff*>(m_animVal.get()); > > auto property = PropertyTearOff::create(*this, AnimValRole, m_property); >- m_animVal = property->createWeakPtr(); >+ m_animVal = makeWeakPtr(property.get()); > return property; > } > >diff --git a/Source/WebCore/svg/properties/SVGAnimatedTransformListPropertyTearOff.h b/Source/WebCore/svg/properties/SVGAnimatedTransformListPropertyTearOff.h >index aa354d6b8c8b47a9fed4f569049f4de272f3f05e..33972024691fcb7334a1140e6356a59825c59e49 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedTransformListPropertyTearOff.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedTransformListPropertyTearOff.h >@@ -38,7 +38,7 @@ public: > return *static_cast<ListPropertyTearOff*>(m_baseVal.get()); > > auto property = SVGTransformList::create(*this, BaseValRole, m_values, m_wrappers); >- m_baseVal = property->createWeakPtr(); >+ m_baseVal = makeWeakPtr(property.get()); > return property; > } > >@@ -48,7 +48,7 @@ public: > return *static_cast<ListPropertyTearOff*>(m_animVal.get()); > > auto property = SVGTransformList::create(*this, AnimValRole, m_values, m_wrappers); >- m_animVal = property->createWeakPtr(); >+ m_animVal = makeWeakPtr(property.get()); > return property; > } > >diff --git a/Source/WebCore/svg/properties/SVGListProperty.h b/Source/WebCore/svg/properties/SVGListProperty.h >index 807492dd905ec6d61b754abd980d19c5c07af72c..a00072d8ff5a803b630fdd0f64fb80ee63cc53ab 100644 >--- a/Source/WebCore/svg/properties/SVGListProperty.h >+++ b/Source/WebCore/svg/properties/SVGListProperty.h >@@ -37,7 +37,7 @@ template<typename PropertyType> > class SVGAnimatedListPropertyTearOff; > > template<typename PropertyType> >-class SVGListProperty : public SVGProperty { >+class SVGListProperty : public SVGProperty, public CanMakeWeakPtr<SVGListProperty<PropertyType>> { > public: > typedef SVGListProperty<PropertyType> Self; > >@@ -162,7 +162,7 @@ public: > m_values->clear(); > > m_values->append(newItem->propertyReference()); >- m_wrappers->append(newItem->createWeakPtr()); >+ m_wrappers->append(makeWeakPtr(newItem.get())); > > commitChange(); > return WTFMove(newItem); >@@ -206,7 +206,7 @@ public: > // It is also associated with our animated property, so it can notify the SVG Element which holds the SVGAnimated*List > // that it has been modified (and thus can call svgAttributeChanged(associatedAttributeName)). > wrapper = ListItemTearOff::create(animatedList, UndefinedRole, m_values->at(index)); >- m_wrappers->at(index) = wrapper->createWeakPtr(); >+ m_wrappers->at(index) = makeWeakPtr(*wrapper); > } > > return wrapper.releaseNonNull(); >@@ -264,7 +264,7 @@ public: > m_values->insert(index, newItem->propertyReference()); > > // Store new wrapper at position 'index', change its underlying value, so mutations of newItem, directly affect the item in the list. >- m_wrappers->insert(index, newItem->createWeakPtr()); >+ m_wrappers->insert(index, makeWeakPtr(newItem.get())); > > commitChange(); > return WTFMove(newItem); >@@ -341,7 +341,7 @@ public: > > // Update the value and the wrapper at the desired position 'index'. > m_values->at(index) = newItem->propertyReference(); >- m_wrappers->at(index) = newItem->createWeakPtr(); >+ m_wrappers->at(index) = makeWeakPtr(newItem.get()); > > commitChange(); > return WTFMove(newItem); >@@ -435,7 +435,7 @@ public: > > // Append the value and wrapper at the end of the list. > m_values->append(newItem->propertyReference()); >- m_wrappers->append(newItem->createWeakPtr()); >+ m_wrappers->append(makeWeakPtr(newItem.get())); > > commitChange(ListModificationAppend); > return WTFMove(newItem); >@@ -453,11 +453,6 @@ public: > return *m_wrappers; > } > >- WeakPtr<SVGListProperty> createWeakPtr() const >- { >- return m_weakPtrFactory.createWeakPtr(*const_cast<SVGListProperty*>(this)); >- } >- > protected: > SVGListProperty(SVGPropertyRole role, PropertyType& values, ListWrapperCache* wrappers) > : m_role(role) >@@ -486,7 +481,6 @@ protected: > bool m_ownsValues; > PropertyType* m_values; > ListWrapperCache* m_wrappers; >- WeakPtrFactory<SVGListProperty> m_weakPtrFactory; > }; > > } >diff --git a/Source/WebCore/svg/properties/SVGMatrixTearOff.h b/Source/WebCore/svg/properties/SVGMatrixTearOff.h >index e0bf0d0827e73f7fc8ffd209309df01e3c299a15..332260a630d4314d7ab254c26e4bc04ee785d17f 100644 >--- a/Source/WebCore/svg/properties/SVGMatrixTearOff.h >+++ b/Source/WebCore/svg/properties/SVGMatrixTearOff.h >@@ -29,8 +29,8 @@ public: > static Ref<SVGMatrixTearOff> create(SVGTransform& parent, SVGMatrixValue& value) > { > ASSERT_UNUSED(value, &parent.propertyReference().svgMatrix() == &value); >- Ref<SVGMatrixTearOff> result = adoptRef(*new SVGMatrixTearOff(parent)); >- parent.addChild(result->m_weakFactory.createWeakPtr(result)); >+ auto result = adoptRef(*new SVGMatrixTearOff(parent)); >+ parent.addChild(makeWeakPtr(result.get())); > return result; > } > >@@ -52,7 +52,6 @@ private: > } > > RefPtr<SVGTransform> m_parent; >- WeakPtrFactory<SVGPropertyTearOffBase> m_weakFactory; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/properties/SVGPropertyTearOff.h b/Source/WebCore/svg/properties/SVGPropertyTearOff.h >index ceb4bf3edd5bd359438f0d6a2da47a5ed09aa668..9008f3b864529c22c2ee672c628871be1a24c786 100644 >--- a/Source/WebCore/svg/properties/SVGPropertyTearOff.h >+++ b/Source/WebCore/svg/properties/SVGPropertyTearOff.h >@@ -35,7 +35,7 @@ public: > }; > > template<typename T> >-class SVGPropertyTearOff : public SVGPropertyTearOffBase { >+class SVGPropertyTearOff : public SVGPropertyTearOffBase, public CanMakeWeakPtr<SVGPropertyTearOff<T>> { > public: > using PropertyType = T; > using Self = SVGPropertyTearOff<PropertyType>; >@@ -125,11 +125,6 @@ public: > return false; > } > >- WeakPtr<SVGPropertyTearOff> createWeakPtr() const >- { >- return m_weakPtrFactory.createWeakPtr(*const_cast<SVGPropertyTearOff*>(this)); >- } >- > protected: > SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& value) > : m_animatedProperty(animatedProperty) >@@ -173,7 +168,6 @@ protected: > SVGPropertyRole m_role; > PropertyType* m_value; > Vector<WeakPtr<SVGPropertyTearOffBase>> m_childTearOffs; >- WeakPtrFactory<SVGPropertyTearOff> m_weakPtrFactory; > bool m_valueIsCopy; > }; > >diff --git a/Source/WebCore/testing/MockCDMFactory.cpp b/Source/WebCore/testing/MockCDMFactory.cpp >index e2fdfbc1ca4ca1b1eb58bc875990da9a4d96c6bc..070a5e15eb62253b57b5d4db7bbffb258114ca97 100644 >--- a/Source/WebCore/testing/MockCDMFactory.cpp >+++ b/Source/WebCore/testing/MockCDMFactory.cpp >@@ -98,7 +98,7 @@ void MockCDMFactory::setSupportedDataTypes(Vector<String>&& types) > > std::unique_ptr<CDMPrivate> MockCDMFactory::createCDM(const String&) > { >- return std::make_unique<MockCDM>(m_weakPtrFactory.createWeakPtr(*this)); >+ return std::make_unique<MockCDM>(makeWeakPtr(*this)); > } > > MockCDM::MockCDM(WeakPtr<MockCDMFactory> factory) >@@ -166,7 +166,7 @@ RefPtr<CDMInstance> MockCDM::createInstance() > { > if (m_factory && !m_factory->canCreateInstances()) > return nullptr; >- return adoptRef(new MockCDMInstance(m_weakPtrFactory.createWeakPtr(*this))); >+ return adoptRef(new MockCDMInstance(makeWeakPtr(*this))); > } > > void MockCDM::loadAndInitialize() >diff --git a/Source/WebCore/testing/MockCDMFactory.h b/Source/WebCore/testing/MockCDMFactory.h >index 418d390bf06d7fb7ddf90ea78435abadb5aaedd8..216d29a0a7c3376d833899d1540027b283ae83f4 100644 >--- a/Source/WebCore/testing/MockCDMFactory.h >+++ b/Source/WebCore/testing/MockCDMFactory.h >@@ -39,7 +39,7 @@ > > namespace WebCore { > >-class MockCDMFactory : public RefCounted<MockCDMFactory>, private CDMFactory { >+class MockCDMFactory : public RefCounted<MockCDMFactory>, public CanMakeWeakPtr<MockCDMFactory>, private CDMFactory { > public: > static Ref<MockCDMFactory> create() { return adoptRef(*new MockCDMFactory); } > ~MockCDMFactory(); >@@ -90,11 +90,10 @@ private: > bool m_canCreateInstances { true }; > bool m_supportsServerCertificates { true }; > bool m_supportsSessions { true }; >- WeakPtrFactory<MockCDMFactory> m_weakPtrFactory; > HashMap<String, Vector<Ref<SharedBuffer>>> m_sessions; > }; > >-class MockCDM : public CDMPrivate { >+class MockCDM : public CDMPrivate, public CanMakeWeakPtr<MockCDM> { > public: > MockCDM(WeakPtr<MockCDMFactory>); > >@@ -120,7 +119,6 @@ private: > std::optional<String> sanitizeSessionId(const String&) const final; > > WeakPtr<MockCDMFactory> m_factory; >- WeakPtrFactory<MockCDM> m_weakPtrFactory; > }; > > class MockCDMInstance : public CDMInstance { >diff --git a/Source/WebCore/workers/service/ExtendableEvent.h b/Source/WebCore/workers/service/ExtendableEvent.h >index f3a5442ce1d0e337397995c962d0641fd11981f5..9038caae3e54881a2702b90f64ebf3efff983bff 100644 >--- a/Source/WebCore/workers/service/ExtendableEvent.h >+++ b/Source/WebCore/workers/service/ExtendableEvent.h >@@ -35,7 +35,7 @@ namespace WebCore { > > class DOMPromise; > >-class ExtendableEvent : public Event { >+class ExtendableEvent : public Event, public CanMakeWeakPtr<ExtendableEvent> { > public: > static Ref<ExtendableEvent> create(const AtomicString& type, const ExtendableEventInit& initializer, IsTrusted isTrusted = IsTrusted::No) > { >@@ -55,14 +55,11 @@ protected: > WEBCORE_EXPORT ExtendableEvent(const AtomicString&, const ExtendableEventInit&, IsTrusted); > ExtendableEvent(const AtomicString&, bool bubbles, bool cancelable); > >- WeakPtr<ExtendableEvent> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > void addExtendLifetimePromise(Ref<DOMPromise>&&); > > private: > unsigned m_pendingPromiseCount { 0 }; > HashSet<Ref<DOMPromise>> m_extendLifetimePromises; >- WeakPtrFactory<ExtendableEvent> m_weakPtrFactory; > WTF::Function<void(HashSet<Ref<DOMPromise>>&&)> m_whenAllExtendLifetimePromisesAreSettledHandler; > }; > >diff --git a/Source/WebCore/workers/service/FetchEvent.cpp b/Source/WebCore/workers/service/FetchEvent.cpp >index 20e0c809f44d6871aabf713d204b6f2156cc3e61..a054e843cf06ad7e7818c77bc3214af993c77eae 100644 >--- a/Source/WebCore/workers/service/FetchEvent.cpp >+++ b/Source/WebCore/workers/service/FetchEvent.cpp >@@ -66,7 +66,7 @@ ExceptionOr<void> FetchEvent::respondWith(Ref<DOMPromise>&& promise) > m_respondPromise = WTFMove(promise); > addExtendLifetimePromise(*m_respondPromise); > >- m_respondPromise->whenSettled([this, weakThis = createWeakPtr()] () { >+ m_respondPromise->whenSettled([this, weakThis = makeWeakPtr(*this)] () { > if (!weakThis) > return; > promiseIsSettled(); >diff --git a/Source/WebCore/workers/service/server/SWServer.h b/Source/WebCore/workers/service/server/SWServer.h >index cf5ecc165e48b327a02b24a03ff4c534c68387ca..49aec184ffaa99c86cd134a576034a492c6cd970 100644 >--- a/Source/WebCore/workers/service/server/SWServer.h >+++ b/Source/WebCore/workers/service/server/SWServer.h >@@ -65,7 +65,7 @@ class Timer; > class SWServer { > WTF_MAKE_FAST_ALLOCATED; > public: >- class Connection { >+ class Connection : public CanMakeWeakPtr<Connection> { > WTF_MAKE_FAST_ALLOCATED; > friend class SWServer; > public: >@@ -74,8 +74,6 @@ public: > using Identifier = SWServerConnectionIdentifier; > Identifier identifier() const { return m_identifier; } > >- auto& weakPtrFactory() { return m_weakFactory; } >- > WEBCORE_EXPORT void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&); > SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) { return m_server.doRegistrationMatching(topOrigin, clientURL); } > void resolveRegistrationReadyRequests(SWServerRegistration&); >@@ -114,7 +112,6 @@ public: > > SWServer& m_server; > Identifier m_identifier; >- WeakPtrFactory<Connection> m_weakFactory; > Vector<RegistrationReadyRequest> m_registrationReadyRequests; > }; > >diff --git a/Source/WebCore/xml/DOMParser.cpp b/Source/WebCore/xml/DOMParser.cpp >index daf2db6d7b8b83db7f7bf4d111e64fef60bb96e8..2713e593d4374676f10502de96e0d1c6832d6ecc 100644 >--- a/Source/WebCore/xml/DOMParser.cpp >+++ b/Source/WebCore/xml/DOMParser.cpp >@@ -25,7 +25,7 @@ > namespace WebCore { > > inline DOMParser::DOMParser(Document& contextDocument) >- : m_contextDocument(contextDocument.createWeakPtr()) >+ : m_contextDocument(makeWeakPtr(contextDocument)) > { > } > >diff --git a/Source/WebKit/NetworkProcess/NetworkLoadChecker.h b/Source/WebKit/NetworkProcess/NetworkLoadChecker.h >index ec74892706f80ca0329b9c0dfd4d495d60680518..1442639e2575a952f4e75ff4454e80a5946af839 100644 >--- a/Source/WebKit/NetworkProcess/NetworkLoadChecker.h >+++ b/Source/WebKit/NetworkProcess/NetworkLoadChecker.h >@@ -44,7 +44,7 @@ namespace WebKit { > class NetworkConnectionToWebProcess; > class NetworkCORSPreflightChecker; > >-class NetworkLoadChecker : public WebCore::ContentSecurityPolicyClient { >+class NetworkLoadChecker : public WebCore::ContentSecurityPolicyClient, public CanMakeWeakPtr<NetworkLoadChecker> { > public: > NetworkLoadChecker(NetworkConnectionToWebProcess&, uint64_t webPageID, uint64_t webFrameID, ResourceLoadIdentifier, WebCore::FetchOptions&&, PAL::SessionID, WebCore::HTTPHeaderMap&&, WebCore::URL&&, RefPtr<WebCore::SecurityOrigin>&&, WebCore::PreflightPolicy, String&& referrer); > ~NetworkLoadChecker(); >@@ -69,8 +69,6 @@ public: > const WebCore::URL& url() const { return m_url; } > WebCore::StoredCredentialsPolicy storedCredentialsPolicy() const { return m_storedCredentialsPolicy; } > >- WeakPtrFactory<NetworkLoadChecker>& weakPtrFactory() { return m_weakFactory; } >- > private: > WebCore::ContentSecurityPolicy* contentSecurityPolicy(); > bool isChecking() const { return !!m_corsPreflightChecker; } >@@ -134,7 +132,6 @@ private: > WebCore::PreflightPolicy m_preflightPolicy; > String m_dntHeaderValue; > String m_referrer; >- WeakPtrFactory<NetworkLoadChecker> m_weakFactory; > }; > > } >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 23652bafd241744e8013ef1303b64d4822a4f19d..3fb81646c9fee8448bec1f2f2a5e403d91ddee4c 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -647,7 +647,7 @@ void NetworkProcess::canAuthenticateAgainstProtectionSpace(NetworkResourceLoader > void NetworkProcess::canAuthenticateAgainstProtectionSpace(PreconnectTask& preconnectTask, const WebCore::ProtectionSpace& protectionSpace) > { > uint64_t loaderID = generateCanAuthenticateIdentifier(); >- m_waitingPreconnectTasks.set(loaderID, preconnectTask.createWeakPtr()); >+ m_waitingPreconnectTasks.set(loaderID, makeWeakPtr(preconnectTask)); > parentProcessConnection()->send(Messages::NetworkProcessProxy::CanAuthenticateAgainstProtectionSpace(loaderID, preconnectTask.pageID(), preconnectTask.frameID(), protectionSpace), 0); > } > #endif >diff --git a/Source/WebKit/NetworkProcess/PreconnectTask.h b/Source/WebKit/NetworkProcess/PreconnectTask.h >index 7af0188c7af1780fcc1856bbc5eeb4bd278c460f..fcef9da2903e252c8e2ad9512eba0b55b4cfab58 100644 >--- a/Source/WebKit/NetworkProcess/PreconnectTask.h >+++ b/Source/WebKit/NetworkProcess/PreconnectTask.h >@@ -37,7 +37,7 @@ namespace WebKit { > class NetworkLoad; > class NetworkLoadParameters; > >-class PreconnectTask final : public NetworkLoadClient { >+class PreconnectTask final : public NetworkLoadClient, public CanMakeWeakPtr<PreconnectTask> { > public: > explicit PreconnectTask(NetworkLoadParameters&&, WTF::CompletionHandler<void(const WebCore::ResourceError&)>&& completionHandler = { }); > ~PreconnectTask(); >@@ -47,8 +47,6 @@ public: > > void continueCanAuthenticateAgainstProtectionSpace(bool); > >- WeakPtr<PreconnectTask> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } >- > private: > // NetworkLoadClient. > bool isSynchronous() const final { return false; } >@@ -66,7 +64,6 @@ private: > std::unique_ptr<NetworkLoad> m_networkLoad; > WTF::CompletionHandler<void(const WebCore::ResourceError&)> m_completionHandler; > WebCore::Timer m_timeoutTimer; >- WeakPtrFactory<PreconnectTask> m_weakFactory; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h >index e2973b2b56edf2bd3953d6e9d40b0218f81e037c..cdfc3483a0491644a551f4a2626d92d6cfd8a63c 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h >@@ -53,7 +53,7 @@ namespace CacheStorage { > using CacheIdentifier = uint64_t; > using LockCount = uint64_t; > >-class Engine : public RefCounted<Engine> { >+class Engine : public RefCounted<Engine>, public CanMakeWeakPtr<Engine> { > public: > ~Engine(); > >@@ -90,8 +90,6 @@ public: > void clearAllCaches(WTF::CallbackAggregator&); > void clearCachesForOrigin(const WebCore::SecurityOriginData&, WTF::CallbackAggregator&); > >- WeakPtrFactory<Engine>& weakPtrFactory() { return m_weakFactory; } >- > private: > static Engine& defaultEngine(); > explicit Engine(String&& rootPath); >@@ -119,7 +117,6 @@ private: > std::optional<NetworkCache::Salt> m_salt; > HashMap<CacheIdentifier, LockCount> m_cacheLocks; > Vector<WebCore::DOMCacheEngine::CompletionCallback> m_initializationCallbacks; >- WeakPtrFactory<Engine> m_weakFactory; > HashMap<uint64_t, WebCore::DOMCacheEngine::CompletionCallback> m_pendingWriteCallbacks; > HashMap<uint64_t, CompletionHandler<void(const NetworkCache::Data&, int error)>> m_pendingReadCallbacks; > uint64_t m_pendingCallbacksCounter { 0 }; >diff --git a/Source/WebKit/Shared/Authentication/AuthenticationManager.h b/Source/WebKit/Shared/Authentication/AuthenticationManager.h >index 4b14ddeddcfbb73eb8efebf47a8bcc21565641ac..df54ceb591f759f74cbee67ae8069bff42756444 100644 >--- a/Source/WebKit/Shared/Authentication/AuthenticationManager.h >+++ b/Source/WebKit/Shared/Authentication/AuthenticationManager.h >@@ -59,7 +59,7 @@ enum class AuthenticationChallengeDisposition { > }; > using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>; > >-class AuthenticationManager : public NetworkProcessSupplement, public IPC::MessageReceiver { >+class AuthenticationManager : public NetworkProcessSupplement, public IPC::MessageReceiver, public CanMakeWeakPtr<AuthenticationManager> { > WTF_MAKE_NONCOPYABLE(AuthenticationManager); > public: > explicit AuthenticationManager(ChildProcess&); >@@ -115,8 +115,6 @@ private: > ChildProcess& m_process; > > HashMap<uint64_t, Challenge> m_challenges; >- >- WeakPtrFactory<AuthenticationManager> m_weakPtrFactory; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/APIAttachment.cpp b/Source/WebKit/UIProcess/API/APIAttachment.cpp >index 04e0717e3c7f32ac96c97ff8990b5fa3cff29cda..7e009d6b2e559cd85b98466812119a4c8b9696e2 100644 >--- a/Source/WebKit/UIProcess/API/APIAttachment.cpp >+++ b/Source/WebKit/UIProcess/API/APIAttachment.cpp >@@ -40,7 +40,7 @@ Ref<Attachment> Attachment::create(const WTF::String& identifier, WebKit::WebPag > > Attachment::Attachment(const WTF::String& identifier, WebKit::WebPageProxy& webPage) > : m_identifier(identifier) >- , m_webPage(webPage.createWeakPtr()) >+ , m_webPage(makeWeakPtr(webPage)) > { > } > >diff --git a/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp b/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp >index 914952ea60267d604627df552e1f708312e6e577..780a15e96d3c36246bb5d5a41c7127b2abdd131c 100644 >--- a/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp >+++ b/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp >@@ -69,7 +69,7 @@ void WebPaymentCoordinatorProxy::canMakePayments(bool& reply) > > void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID) > { >- auto weakThis = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, [weakThis, requestID](bool canMakePayments) { > auto paymentCoordinatorProxy = weakThis.get(); > if (!paymentCoordinatorProxy) >@@ -81,7 +81,7 @@ void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& mer > > void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID) > { >- auto weakThis = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > platformOpenPaymentSetup(merchantIdentifier, domainName, [weakThis, requestID](bool result) { > auto paymentCoordinatorProxy = weakThis.get(); > if (!paymentCoordinatorProxy) >diff --git a/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h b/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h >index c820bd586f44862c7e9c55dfed09d3ef5ae69010..085019da06e32fb0f4ec58991535486feba7f8da 100644 >--- a/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h >+++ b/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h >@@ -55,7 +55,7 @@ namespace WebKit { > > class WebPageProxy; > >-class WebPaymentCoordinatorProxy : private IPC::MessageReceiver { >+class WebPaymentCoordinatorProxy : private IPC::MessageReceiver, public CanMakeWeakPtr<WebPaymentCoordinatorProxy> { > public: > explicit WebPaymentCoordinatorProxy(WebPageProxy&); > ~WebPaymentCoordinatorProxy(); >@@ -107,7 +107,6 @@ private: > void platformCompletePaymentSession(const std::optional<WebCore::PaymentAuthorizationResult>&); > > WebPageProxy& m_webPageProxy; >- WeakPtrFactory<WebPaymentCoordinatorProxy> m_weakPtrFactory; > > enum class State { > // Idle - Nothing's happening. >diff --git a/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm b/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm >index dff8dec92158cd1bda691701ca8dd2b57eaa22ee..74159383f195427db9760a8c01ec7067a67c6f95 100644 >--- a/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm >+++ b/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm >@@ -51,7 +51,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(*this); >+ auto weakThis = makeWeakPtr(*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) >diff --git a/Source/WebKit/UIProcess/ApplicationStateTracker.h b/Source/WebKit/UIProcess/ApplicationStateTracker.h >index a0e93bdbe76e0f9903296a16ae2c2c8f48b3ed03..4eb5b2bc4fee3d20bf36b1b1bb226cb856028280 100644 >--- a/Source/WebKit/UIProcess/ApplicationStateTracker.h >+++ b/Source/WebKit/UIProcess/ApplicationStateTracker.h >@@ -37,7 +37,7 @@ OBJC_CLASS UIView; > > namespace WebKit { > >-class ApplicationStateTracker { >+class ApplicationStateTracker : public CanMakeWeakPtr<ApplicationStateTracker> { > public: > ApplicationStateTracker(UIView *, SEL didEnterBackgroundSelector, SEL didCreateWindowContextSelector, SEL didFinishSnapshottingAfterEnteringBackgroundSelector, SEL willEnterForegroundSelector); > ~ApplicationStateTracker(); >@@ -58,8 +58,6 @@ private: > > bool m_isInBackground; > >- WeakPtrFactory<ApplicationStateTracker> m_weakPtrFactory; >- > RetainPtr<BKSApplicationStateMonitor> m_applicationStateMonitor; > > id m_didEnterBackgroundObserver; >diff --git a/Source/WebKit/UIProcess/ApplicationStateTracker.mm b/Source/WebKit/UIProcess/ApplicationStateTracker.mm >index c6523a38ad863f8fbc52e4d182e0e87a0c779836..5b03afb4251522e4b68de9a76f4a1da9f5ef5abb 100644 >--- a/Source/WebKit/UIProcess/ApplicationStateTracker.mm >+++ b/Source/WebKit/UIProcess/ApplicationStateTracker.mm >@@ -93,7 +93,7 @@ ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackg > ASSERT(window); > > NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; >- auto weakThis = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > m_didCreateWindowContextObserver = [notificationCenter addObserverForName:@"_UIWindowDidCreateWindowContextNotification" object:window queue:nil usingBlock:[weakThis](NSNotification *) { > auto applicationStateTracker = weakThis.get(); > if (!applicationStateTracker) >diff --git a/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp b/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp >index 2b3ba77f31c1187a580992b601612289da62f025..35378b0dc3496571a76ad6058cc50f26a4953b8c 100644 >--- a/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp >+++ b/Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp >@@ -108,10 +108,7 @@ void ViewGestureController::didEndGesture() > > void ViewGestureController::setAlternateBackForwardListSourcePage(WebPageProxy* page) > { >- if (page) >- m_alternateBackForwardListSourcePage = page->createWeakPtr(); >- else >- m_alternateBackForwardListSourcePage.clear(); >+ m_alternateBackForwardListSourcePage = makeWeakPtr(page); > } > > bool ViewGestureController::canSwipeInDirection(SwipeDirection direction) const >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >index e3994d3df567c83bf1ba73f95772f3b6ce8372ba..164bac3bd65ffc0cca679fb8dd064857e3ed82e9 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >@@ -124,7 +124,7 @@ typedef id <NSValidatedUserInterfaceItem> ValidationItem; > typedef Vector<RetainPtr<ValidationItem>> ValidationVector; > typedef HashMap<String, ValidationVector> ValidationMap; > >-class WebViewImpl { >+class WebViewImpl : public CanMakeWeakPtr<WebViewImpl> { > WTF_MAKE_FAST_ALLOCATED; > WTF_MAKE_NONCOPYABLE(WebViewImpl); > public: >@@ -578,8 +578,6 @@ private: > #endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER) > #endif // HAVE(TOUCH_BAR) > >- WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > bool supportsArbitraryLayoutModes() const; > float intrinsicDeviceScaleFactor() const; > void dispatchSetTopContentInset(); >@@ -613,8 +611,6 @@ private: > std::unique_ptr<PageClient> m_pageClient; > Ref<WebPageProxy> m_page; > >- WeakPtrFactory<WebViewImpl> m_weakPtrFactory; >- > bool m_willBecomeFirstResponderAgain { false }; > bool m_inBecomeFirstResponder { false }; > bool m_inResignFirstResponder { false }; >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >index 6f94bc6ca7e620da364280f7014df910c2af6815..b3fbba45d81823138fd70cf42201e65c40c3d48c 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >@@ -1574,7 +1574,7 @@ void WebViewImpl::updateWindowAndViewFrames() > > m_didScheduleWindowAndViewFrameUpdate = true; > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > dispatch_async(dispatch_get_main_queue(), [weakThis] { > if (!weakThis) > return; >@@ -1706,7 +1706,7 @@ void WebViewImpl::setTopContentInset(CGFloat contentInset) > > m_didScheduleSetTopContentInset = true; > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > dispatch_async(dispatch_get_main_queue(), [weakThis] { > if (!weakThis) > return; >@@ -2069,7 +2069,7 @@ void WebViewImpl::viewDidMoveToWindow() > m_page->layerHostingModeDidChange(); > > if (!m_flagsChangedEventMonitor) { >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > m_flagsChangedEventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskFlagsChanged handler:[weakThis] (NSEvent *flagsChangedEvent) { > if (weakThis) > weakThis->postFakeMouseMovedEventForFlagsChangedEvent(flagsChangedEvent); >@@ -2249,7 +2249,7 @@ void WebViewImpl::prepareForMoveToWindow(NSWindow *targetWindow, WTF::Function<v > > m_shouldDeferViewInWindowChanges = false; > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > m_page->installActivityStateChangeCompletionHandler([weakThis, completionHandler = WTFMove(completionHandler)]() { > completionHandler(); > >@@ -2786,7 +2786,7 @@ bool WebViewImpl::validateUserInterfaceItem(id <NSValidatedUserInterfaceItem> it > // If we are not already awaiting validation for this command, start the asynchronous validation process. > // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time > // we asked for the same command; there is no guarantee the answer is still valid. >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > m_page->validateCommand(commandName, [weakThis](const String& commandName, bool isEnabled, int32_t state, WebKit::CallbackBase::Error error) { > if (!weakThis) > return; >@@ -3036,7 +3036,7 @@ void WebViewImpl::requestCandidatesForSelectionIfNeeded() > #if HAVE(ADVANCED_SPELL_CHECKING) > NSRange selectedRange = NSMakeRange(postLayoutData.candidateRequestStartPosition, postLayoutData.selectedTextLength); > NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection; >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > m_lastCandidateRequestSequenceNumber = [[NSSpellChecker sharedSpellChecker] requestCandidatesForSelectedRange:selectedRange inString:postLayoutData.paragraphContextForCandidateRequest types:checkingTypes options:nil inSpellDocumentWithTag:spellCheckerDocumentTag() completionHandler:[weakThis](NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates) { > dispatch_async(dispatch_get_main_queue(), ^{ > if (!weakThis) >@@ -4365,7 +4365,7 @@ void WebViewImpl::interpretKeyEvent(NSEvent *event, void(^completionHandler)(BOO > } > > LOG(TextInput, "-> handleEventByInputMethod:%p %@", event, event); >- [inputContext() handleEventByInputMethod:event completionHandler:[weakThis = createWeakPtr(), capturedEvent = retainPtr(event), capturedBlock = makeBlockPtr(completionHandler)](BOOL handled) { >+ [inputContext() handleEventByInputMethod:event completionHandler:[weakThis = makeWeakPtr(*this), capturedEvent = retainPtr(event), capturedBlock = makeBlockPtr(completionHandler)](BOOL handled) { > if (!weakThis) { > capturedBlock(NO, { }); > return; >@@ -4559,7 +4559,7 @@ void WebViewImpl::firstRectForCharacterRange(NSRange range, void(^completionHand > return; > } > >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > m_page->firstRectForCharacterRangeAsync(range, [weakThis, completionHandler](const WebCore::IntRect& rect, const EditingRange& actualRange, WebKit::CallbackBase::Error error) { > auto completionHandlerBlock = (void (^)(NSRect, NSRange))completionHandler.get(); > if (!weakThis) { >@@ -4734,7 +4734,7 @@ bool WebViewImpl::performKeyEquivalent(NSEvent *event) > // this event. This lets webpages have a crack at intercepting key-modified keypresses. > // FIXME: Why is the firstResponder check needed? > if (m_view.getAutoreleased() == [m_view window].firstResponder) { >- interpretKeyEvent(event, [weakThis = createWeakPtr(), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) { >+ interpretKeyEvent(event, [weakThis = makeWeakPtr(*this), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) { > if (weakThis) > weakThis->m_page->handleKeyboardEvent(NativeWebKeyboardEvent(capturedEvent.get(), handledByInputMethod, false, commands)); > }); >@@ -4752,7 +4752,7 @@ void WebViewImpl::keyUp(NSEvent *event) > LOG(TextInput, "keyUp:%p %@", event, event); > > m_isTextInsertionReplacingSoftSpace = false; >- interpretKeyEvent(event, [weakThis = createWeakPtr(), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) { >+ interpretKeyEvent(event, [weakThis = makeWeakPtr(*this), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) { > ASSERT(!handledByInputMethod || commands.isEmpty()); > if (weakThis) > weakThis->m_page->handleKeyboardEvent(NativeWebKeyboardEvent(capturedEvent.get(), handledByInputMethod, weakThis->m_isTextInsertionReplacingSoftSpace, commands)); >@@ -4781,7 +4781,7 @@ void WebViewImpl::keyDown(NSEvent *event) > } > > m_isTextInsertionReplacingSoftSpace = false; >- interpretKeyEvent(event, [weakThis = createWeakPtr(), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) { >+ interpretKeyEvent(event, [weakThis = makeWeakPtr(*this), capturedEvent = retainPtr(event)](BOOL handledByInputMethod, const Vector<WebCore::KeypressCommand>& commands) { > ASSERT(!handledByInputMethod || commands.isEmpty()); > if (weakThis) > weakThis->m_page->handleKeyboardEvent(NativeWebKeyboardEvent(capturedEvent.get(), handledByInputMethod, weakThis->m_isTextInsertionReplacingSoftSpace, commands)); >@@ -4810,7 +4810,7 @@ void WebViewImpl::flagsChanged(NSEvent *event) > if (m_ignoresNonWheelEvents) \ > return; \ > if (NSTextInputContext *context = [m_view inputContext]) { \ >- auto weakThis = createWeakPtr(); \ >+ auto weakThis = makeWeakPtr(*this); \ > RetainPtr<NSEvent> retainedEvent = event; \ > [context handleEvent:event completionHandler:[weakThis, retainedEvent] (BOOL handled) { \ > if (!weakThis) \ >@@ -4833,7 +4833,7 @@ void WebViewImpl::flagsChanged(NSEvent *event) > if (m_ignoresNonWheelEvents) \ > return; \ > if (NSTextInputContext *context = [m_view inputContext]) { \ >- auto weakThis = createWeakPtr(); \ >+ auto weakThis = makeWeakPtr(*this); \ > RetainPtr<NSEvent> retainedEvent = event; \ > [context handleEvent:event completionHandler:[weakThis, retainedEvent] (BOOL handled) { \ > if (!weakThis) \ >diff --git a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp b/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp >index 3afdd135c1af814681b200250307e362d79117b5..48a60eba13042f22fc16a57627ca55c59ad92d5a 100644 >--- a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp >+++ b/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.cpp >@@ -58,7 +58,7 @@ void WebCredentialsMessengerProxy::makeCredential(uint64_t messageId, const Vect > } > // FIXME(183534): Weak pointers doesn't work in another thread because of race condition. > // FIXME(183534): Unify callbacks. >- auto weakThis = m_weakFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > auto callback = [weakThis, messageId] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& attestationObject) { > if (!weakThis) > return; >@@ -79,7 +79,7 @@ void WebCredentialsMessengerProxy::getAssertion(uint64_t messageId, const Vector > exceptionReply(messageId, { WebCore::NotAllowedError, ASCIILiteral("No avaliable authenticators.") }); > // FIXME(183534): Weak pointers doesn't work in another thread because of race condition. > // FIXME(183534): Unify callbacks. >- auto weakThis = m_weakFactory.createWeakPtr(*this); >+ auto weakThis = makeWeakPtr(*this); > auto callback = [weakThis, messageId] (const Vector<uint8_t>& credentialId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature, const Vector<uint8_t>& userHandle) { > if (weakThis) > weakThis->getAssertionReply(messageId, credentialId, authenticatorData, signature, userHandle); >diff --git a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h b/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h >index 0c2a4de15e29a753aac34f79dd90793bd6341286..9d74c97270b783e87e4f8e52f28da0ea290c70c0 100644 >--- a/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h >+++ b/Source/WebKit/UIProcess/CredentialManagement/WebCredentialsMessengerProxy.h >@@ -44,7 +44,7 @@ namespace WebKit { > > class WebPageProxy; > >-class WebCredentialsMessengerProxy : private IPC::MessageReceiver { >+class WebCredentialsMessengerProxy : private IPC::MessageReceiver, public CanMakeWeakPtr<WebCredentialsMessengerProxy> { > WTF_MAKE_NONCOPYABLE(WebCredentialsMessengerProxy); > public: > explicit WebCredentialsMessengerProxy(WebPageProxy&); >@@ -67,7 +67,6 @@ private: > > WebPageProxy& m_webPageProxy; > std::unique_ptr<WebCore::LocalAuthenticator> m_authenticator; >- WeakPtrFactory<WebCredentialsMessengerProxy> m_weakFactory; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp >index 28dac213887d251b9165a6e46836963de4cb1b6f..96326ebfa5a7f8ccad4985c1da38e19f18e43831 100644 >--- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp >+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp >@@ -99,7 +99,7 @@ WebPageProxy* DownloadProxy::originatingPage() const > > void DownloadProxy::setOriginatingPage(WebPageProxy* page) > { >- m_originatingPage = page ? page->createWeakPtr() : nullptr; >+ m_originatingPage = makeWeakPtr(page); > } > > void DownloadProxy::didStart(const ResourceRequest& request, const String& suggestedFilename) >diff --git a/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h b/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h >index 3ababbcceedce3e79dede0a33931a52f2ef57360..831b18def4bc743670f7536b557ff8355a25929a 100644 >--- a/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h >+++ b/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h >@@ -41,7 +41,7 @@ > > namespace WebKit { > >-class ProcessLauncher : public ThreadSafeRefCounted<ProcessLauncher> { >+class ProcessLauncher : public ThreadSafeRefCounted<ProcessLauncher>, public CanMakeWeakPtr<ProcessLauncher> { > public: > class Client { > public: >@@ -101,7 +101,6 @@ private: > WTF::Win32Handle m_hProcess; > #endif > >- WeakPtrFactory<ProcessLauncher> m_weakPtrFactory; > const LaunchOptions m_launchOptions; > bool m_isLaunching; > ProcessID m_processIdentifier; >diff --git a/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >index 31105e4703c0efd4814cb1536f914c85e308f919..375a1705cd374734b50b081c072cdccc8ad61f8e 100644 >--- a/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >+++ b/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm >@@ -201,7 +201,7 @@ void ProcessLauncher::launchProcess() > > xpc_dictionary_set_value(bootstrapMessage.get(), "extra-initialization-data", extraInitializationData.get()); > >- auto weakProcessLauncher = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakProcessLauncher = makeWeakPtr(*this); > auto errorHandler = [weakProcessLauncher, listeningPort](xpc_object_t event) { > ASSERT(!event || xpc_get_type(event) == XPC_TYPE_ERROR); > >diff --git a/Source/WebKit/UIProcess/ProcessAssertion.h b/Source/WebKit/UIProcess/ProcessAssertion.h >index dc9afd809439c75a039ecebe8658c8ea34dcc3f2..4c919476b73b3954f5d5277c61fba9e8454896f7 100644 >--- a/Source/WebKit/UIProcess/ProcessAssertion.h >+++ b/Source/WebKit/UIProcess/ProcessAssertion.h >@@ -53,7 +53,11 @@ public: > virtual void assertionWillExpireImminently() = 0; > }; > >-class ProcessAssertion { >+class ProcessAssertion >+#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) >+ : public CanMakeWeakPtr<ProcessAssertion> >+#endif >+{ > public: > ProcessAssertion(ProcessID, AssertionState, Function<void()>&& invalidationCallback = { }); > virtual ~ProcessAssertion(); >@@ -72,12 +76,10 @@ protected: > > private: > #if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) >- WeakPtr<ProcessAssertion> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); } > void markAsInvalidated(); > > RetainPtr<BKSProcessAssertion> m_assertion; > Validity m_validity { Validity::Unset }; >- WeakPtrFactory<ProcessAssertion> m_weakFactory; > Function<void()> m_invalidationCallback; > #endif > AssertionState m_assertionState; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 8a3b72799106591f3818a15e0fa244f4b32b855b..e0494c017444cf77395f5e0d53eeaed04bdd9e6f 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -322,7 +322,8 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page> > #endif > , public WebPopupMenuProxy::Client > , public IPC::MessageReceiver >- , public IPC::MessageSender { >+ , public IPC::MessageSender >+ , public CanMakeWeakPtr<WebPageProxy> { > public: > static Ref<WebPageProxy> create(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&); > virtual ~WebPageProxy(); >@@ -1261,8 +1262,6 @@ public: > #if ENABLE(GAMEPAD) > void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible); > #endif >- >- WeakPtr<WebPageProxy> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(*const_cast<WebPageProxy*>(this)); } > > void isLoadingChanged() { activityStateDidChange(WebCore::ActivityState::IsLoading); } > >@@ -2160,8 +2159,6 @@ private: > > bool m_isUsingHighPerformanceWebGL { false }; > >- WeakPtrFactory<WebPageProxy> m_weakPtrFactory; >- > HashMap<String, Ref<WebURLSchemeHandler>> m_urlSchemeHandlersByScheme; > HashMap<uint64_t, Ref<WebURLSchemeHandler>> m_urlSchemeHandlersByIdentifier; > >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >index 3abf8ff51f442b8508b376925f5aad3a8b0685ab..978c3d945c5c083cbcfcf67c842ab2639d0071aa 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >@@ -73,7 +73,7 @@ struct PluginModuleInfo; > > enum class ShouldClearFirst { No, Yes }; > >-class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore> { >+class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore> { > public: > constexpr static uint64_t defaultCacheStoragePerOriginQuota = 50 * 1024 * 1024; > >@@ -183,8 +183,6 @@ public: > void addSecKeyProxyStore(Ref<SecKeyProxyStore>&&); > #endif > >- auto& weakPtrFactory() const { return m_weakFactory; } >- > private: > explicit WebsiteDataStore(PAL::SessionID); > explicit WebsiteDataStore(Configuration, PAL::SessionID); >@@ -215,7 +213,6 @@ private: > > void maybeRegisterWithSessionIDMap(); > >- WeakPtrFactory<WebsiteDataStore> m_weakFactory; > const PAL::SessionID m_sessionID; > > const Configuration m_configuration; >diff --git a/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp b/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp >index 6b339e00914069c9790a98cfcf53d31be67a96f9..8a8e6976d96080984e53e52413d5a3e56b9f3f7c 100644 >--- a/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp >+++ b/Source/WebKit/UIProcess/gtk/WaylandCompositor.cpp >@@ -216,7 +216,7 @@ void WaylandCompositor::Surface::attachBuffer(struct wl_resource* buffer) > > if (buffer) { > auto* compositorBuffer = WaylandCompositor::Buffer::getOrCreate(buffer); >- m_pendingBuffer = compositorBuffer->createWeakPtr(); >+ m_pendingBuffer = makeWeakPtr(*compositorBuffer); > } > } > >diff --git a/Source/WebKit/UIProcess/gtk/WaylandCompositor.h b/Source/WebKit/UIProcess/gtk/WaylandCompositor.h >index aa933343ec817228000a065acf3336f1626c53cc..6e5131193e535d081f38392d7f294b15f620c608 100644 >--- a/Source/WebKit/UIProcess/gtk/WaylandCompositor.h >+++ b/Source/WebKit/UIProcess/gtk/WaylandCompositor.h >@@ -55,7 +55,7 @@ class WaylandCompositor { > public: > static WaylandCompositor& singleton(); > >- class Buffer { >+ class Buffer : public CanMakeWeakPtr<Buffer> { > WTF_MAKE_NONCOPYABLE(Buffer); WTF_MAKE_FAST_ALLOCATED; > public: > static Buffer* getOrCreate(struct wl_resource*); >@@ -67,8 +67,6 @@ public: > EGLImageKHR createImage() const; > WebCore::IntSize size() const; > >- WeakPtr<Buffer> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > Buffer(struct wl_resource*); > static void destroyListenerCallback(struct wl_listener*, void*); >@@ -76,7 +74,6 @@ public: > struct wl_resource* m_resource { nullptr }; > struct wl_listener m_destroyListener; > uint32_t m_busyCount { 0 }; >- WeakPtrFactory<Buffer> m_weakPtrFactory; > }; > > class Surface { >diff --git a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >index 0649d117312331be098f7e443d7da6f1bd841a62..bfc6e75fb26f15565b93846d1b5f8cfffc016312 100644 >--- a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >+++ b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >@@ -163,7 +163,7 @@ ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState, Fun > : m_invalidationCallback(WTFMove(invalidationCallback)) > , m_assertionState(assertionState) > { >- auto weakThis = createWeakPtr(); >+ auto weakThis = makeWeakPtr(*this); > BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) { > if (!acquired) { > RELEASE_LOG_ERROR(ProcessSuspension, " %p - ProcessAssertion() Unable to acquire assertion for process with PID %d", this, pid); >diff --git a/Source/WebKit/UIProcess/mac/DisplayLink.cpp b/Source/WebKit/UIProcess/mac/DisplayLink.cpp >index bc68c302af5494b7bc7da82ee49ad7a5fc1a87d2..bab075bf3c5c4200125a052f04ac2282c2f995c4 100644 >--- a/Source/WebKit/UIProcess/mac/DisplayLink.cpp >+++ b/Source/WebKit/UIProcess/mac/DisplayLink.cpp >@@ -98,7 +98,7 @@ void DisplayLink::resume() > CVReturn DisplayLink::displayLinkCallback(CVDisplayLinkRef displayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data) > { > WebPageProxy* webPageProxy = reinterpret_cast<WebPageProxy*>(data); >- RunLoop::main().dispatch([weakPtr = webPageProxy->createWeakPtr()] { >+ RunLoop::main().dispatch([weakPtr = makeWeakPtr(*webPageProxy)] { > if (auto* proxy = weakPtr.get()) > proxy->process().send(Messages::DrawingArea::DisplayWasRefreshed(), proxy->pageID()); > }); >diff --git a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm >index 9ca83b228b71caee94dced23c28423f6661b14ae..2263bc9585050b089ab3da3e02e2eb729ffb443c 100644 >--- a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm >+++ b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm >@@ -34,7 +34,7 @@ namespace WebKit { > > RemoteLayerTreeDisplayRefreshMonitor::RemoteLayerTreeDisplayRefreshMonitor(PlatformDisplayID displayID, RemoteLayerTreeDrawingArea& drawingArea) > : DisplayRefreshMonitor(displayID) >- , m_drawingArea(drawingArea.createWeakPtr()) >+ , m_drawingArea(makeWeakPtr(drawingArea)) > { > } > >diff --git a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h >index 9af5cb3a81befa5e5cc25a7ec8084de32cf5dfbc..e9ee03e149fd93714e495c5bda09768b63fcc829 100644 >--- a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h >+++ b/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h >@@ -45,7 +45,7 @@ namespace WebKit { > class RemoteLayerTreeContext; > class RemoteLayerTreeDisplayRefreshMonitor; > >-class RemoteLayerTreeDrawingArea : public DrawingArea, public WebCore::GraphicsLayerClient { >+class RemoteLayerTreeDrawingArea : public DrawingArea, public CanMakeWeakPtr<RemoteLayerTreeDrawingArea>, public WebCore::GraphicsLayerClient { > friend class RemoteLayerTreeDisplayRefreshMonitor; > public: > RemoteLayerTreeDrawingArea(WebPage&, const WebPageCreationParameters&); >@@ -54,8 +54,6 @@ public: > uint64_t nextTransactionID() const { return m_currentTransactionID + 1; } > uint64_t lastCommittedTransactionID() const { return m_currentTransactionID; } > >- WeakPtr<RemoteLayerTreeDrawingArea> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); } >- > private: > // DrawingArea > void setNeedsDisplay() override; >@@ -170,8 +168,6 @@ private: > > WebCore::GraphicsLayer* m_contentLayer { nullptr }; > WebCore::GraphicsLayer* m_viewOverlayRootLayer { nullptr }; >- >- WeakPtrFactory<RemoteLayerTreeDrawingArea> m_weakPtrFactory; > }; > > } // namespace WebKit >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h >index fa2ed3282578478b3cf5d081f71c865ef81d7035..4f10ad376d1edfafc65b0f2bbd402b44a495b1fb 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h >@@ -43,7 +43,7 @@ > @class WebView; > @class WebEditorUndoTarget; > >-class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient { >+class WebEditorClient final : public WebCore::EditorClient, public WebCore::TextCheckerClient, public CanMakeWeakPtr<WebEditorClient> { > public: > WebEditorClient(WebView *); > virtual ~WebEditorClient(); >@@ -193,8 +193,6 @@ private: > > enum class EditorStateIsContentEditable { No, Yes, Unset }; > EditorStateIsContentEditable m_lastEditorStateWasContentEditable { EditorStateIsContentEditable::Unset }; >- >- WeakPtrFactory<WebEditorClient> m_weakPtrFactory; > }; > > inline NSSelectionAffinity kit(WebCore::EAffinity affinity) >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >index fce5d7aab4a5b06af95263abca27c0fe2e154865..610f8e083d1e0703f79a915e6d8e2a82d5bbca8c 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm >@@ -1213,7 +1213,7 @@ void WebEditorClient::requestCandidatesForSelection(const VisibleSelection& sele > m_paragraphContextForCandidateRequest = plainText(frame->editor().contextRangeForCandidateRequest().get()); > > NSTextCheckingTypes checkingTypes = NSTextCheckingTypeSpelling | NSTextCheckingTypeReplacement | NSTextCheckingTypeCorrection; >- auto weakEditor = m_weakPtrFactory.createWeakPtr(*this); >+ auto weakEditor = makeWeakPtr(*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)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186407
:
342216
|
342219