WeakPtrFactory should allow downcasting
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Sep 2017 21:31:40 +0000 (21:31 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Sep 2017 21:31:40 +0000 (21:31 +0000)
commiteb42c9d1259563a626911094ffbed35c0c2ec5a2
tree4d24ff671cc9ec493d02e6d638efce63bfab005d
parentbc5e8c109910772017b34f20b2ae23bda35e9afb
WeakPtrFactory should allow downcasting
https://bugs.webkit.org/show_bug.cgi?id=177389
<rdar://problem/34604174>

Reviewed by Geoffrey Garen.

Source/WTF:

In this patch, WeakPtrFactory is enhanced with the ability to create WeakPtrs
of its owner's sub classes and have them point to the same WeakReference.

* wtf/WeakPtr.h:
(WTF::WeakPtr::WeakPtr):
We cannot determine the base class of type T, thus no friends. It is made public
such that WeakPtrFactory with a base class type U can create a derived type T
WeakPtr.
(WTF::WeakPtrFactory::createWeakPtr const):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::Base::foo):
(TestWebKitAPI::Base::createWeakPtr):
(TestWebKitAPI::Derived::foo):
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/WeakPtr.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp