Allow creating WeakPtrs to const objects
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2018 09:30:52 +0000 (09:30 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2018 09:30:52 +0000 (09:30 +0000)
commit70552af6709f71c834eb93b736f10c443fbcd035
tree9e14edb952df8a966a06cdaba9adda12a1964752
parentdc652b394ed28474c4d866a8d17759347b75eb62
Allow creating WeakPtrs to const objects
https://bugs.webkit.org/show_bug.cgi?id=188785

Reviewed by Geoff Garen.

Source/WebCore:

Remove some unneeded const_casts.

* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::MediaQueryEvaluator):
(WebCore::MediaQueryEvaluator::evaluate const):
* css/MediaQueryEvaluator.h:
* rendering/FloatingObjects.cpp:
(WebCore::ComputeFloatOffsetAdapter::ComputeFloatOffsetAdapter):
(WebCore::ComputeFloatOffsetForFloatLayoutAdapter::ComputeFloatOffsetForFloatLayoutAdapter):
(WebCore::ComputeFloatOffsetForLineLayoutAdapter::ComputeFloatOffsetForLineLayoutAdapter):
(WebCore::FindNextFloatLogicalBottomAdapter::FindNextFloatLogicalBottomAdapter):
(WebCore::FloatingObjects::FloatingObjects):
* rendering/FloatingObjects.h:
(WebCore::FloatingObjects::renderer const):

Source/WTF:

const Foo foo;
WeakPtr<const Foo> weakConstFoo = makeWeakPtr(foo);

* wtf/WeakPtr.h:
(WTF::WeakPtrFactory::createWeakPtr const):

Add a separate factory function for const T.
The underlying WeakReference is kept non-const in all cases.

Tools:

* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::Base::weakPtrFactory const):
(TestWebKitAPI::TEST):
(TestWebKitAPI::Base::weakPtrFactory): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235315 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/WeakPtr.h
Source/WebCore/ChangeLog
Source/WebCore/css/MediaQueryEvaluator.cpp
Source/WebCore/css/MediaQueryEvaluator.h
Source/WebCore/rendering/FloatingObjects.cpp
Source/WebCore/rendering/FloatingObjects.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp