Changeset 245857 in webkit
- Timestamp:
- May 29, 2019, 11:22:00 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 53 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/WeakHashSet.h (modified) (6 diffs)
-
Source/WTF/wtf/WeakPtr.h (modified) (11 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (modified) (1 diff)
-
Source/WebCore/Modules/encryptedmedia/MediaKeySession.h (modified) (2 diffs)
-
Source/WebCore/css/CSSFontFace.cpp (modified) (1 diff)
-
Source/WebCore/css/CSSFontFace.h (modified) (1 diff)
-
Source/WebCore/css/parser/CSSDeferredParser.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSDeferredParser.h (modified) (1 diff)
-
Source/WebCore/dom/ContainerNode.h (modified) (2 diffs)
-
Source/WebCore/dom/Document.h (modified) (1 diff)
-
Source/WebCore/dom/Element.h (modified) (1 diff)
-
Source/WebCore/dom/FullscreenManager.cpp (modified) (1 diff)
-
Source/WebCore/dom/FullscreenManager.h (modified) (1 diff)
-
Source/WebCore/html/FormAssociatedElement.cpp (modified) (1 diff)
-
Source/WebCore/html/FormAssociatedElement.h (modified) (1 diff)
-
Source/WebCore/html/HTMLMediaElement.h (modified) (2 diffs)
-
Source/WebCore/loader/MediaResourceLoader.cpp (modified) (1 diff)
-
Source/WebCore/page/DOMWindowProperty.cpp (modified) (1 diff)
-
Source/WebCore/page/DOMWindowProperty.h (modified) (1 diff)
-
Source/WebCore/page/FrameViewLayoutContext.cpp (modified) (1 diff)
-
Source/WebCore/page/FrameViewLayoutContext.h (modified) (2 diffs)
-
Source/WebCore/page/UndoItem.cpp (modified) (1 diff)
-
Source/WebCore/page/UndoItem.h (modified) (1 diff)
-
Source/WebCore/platform/ScrollView.h (modified) (2 diffs)
-
Source/WebCore/platform/Widget.cpp (modified) (1 diff)
-
Source/WebCore/platform/Widget.h (modified) (1 diff)
-
Source/WebCore/platform/encryptedmedia/CDMInstanceSession.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (2 diffs)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (modified) (4 diffs)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (modified) (9 diffs)
-
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (modified) (9 diffs)
-
Source/WebCore/rendering/RenderBlockFlow.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderBlockFlow.h (modified) (1 diff)
-
Source/WebCore/rendering/RenderMultiColumnFlow.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderMultiColumnFlow.h (modified) (1 diff)
-
Source/WebCore/rendering/RenderTable.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderTable.h (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (modified) (1 diff)
-
Source/WebKit/Shared/WebBackForwardListItem.cpp (modified) (1 diff)
-
Source/WebKit/Shared/WebBackForwardListItem.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Authentication/cocoa/SecKeyProxyStore.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebProcessProxy.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r245796 r245857 1 2019-05-28 Geoffrey Garen <ggaren@apple.com> 2 3 WeakPtr breaks vtables when upcasting to base classes 4 https://bugs.webkit.org/show_bug.cgi?id=188799 5 6 Reviewed by Youenn Fablet. 7 8 This patch switches from reinterpret_cast to static_cast when loading 9 from WeakReference storage. 10 11 We know which type to cast *to* because it's specified by the type of 12 the calling WeakPtr. 13 14 We know which type to cast *from* because it's specified by a typedef 15 in CanMakeWeakPtr. 16 17 (Our convention is that we store a pointer to the class that derives 18 from CanMakeWeakPtr. We cast from that pointer to derived pointers when 19 we get(). This means that #include of the derived type header is now 20 required in order to get() the pointer.) 21 22 * wtf/WeakHashSet.h: 23 (WTF::HashTraits<Ref<WeakReference>>::isReleasedWeakValue): Definition 24 is now eagerly required because WeakReference is not a template anymore. 25 26 (WTF::WeakHashSet::WeakHashSetConstIterator::get const): 27 (WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets): 28 (WTF::WeakHashSet::remove): 29 (WTF::WeakHashSet::contains const): 30 (WTF::WeakHashSet::computesEmpty const): 31 (WTF::WeakHashSet::hasNullReferences const): 32 (WTF::WeakHashSet::computeSize const): 33 (WTF::HashTraits<Ref<WeakReference<T>>>::isReleasedWeakValue): Deleted. 34 Updated for new WeakReference get() API. 35 36 * wtf/WeakPtr.h: Use a macro for TestAPI support. We can't use template 37 specialization because WeakReference is not a class template anymore. 38 (Or maybe we could have kept it working with a dummy template argument? 39 Felt weird, so I switched.) 40 41 (WTF::WeakReference::create): 42 (WTF::WeakReference::~WeakReference): 43 (WTF::WeakReference::get const): 44 (WTF::WeakReference::operator bool const): 45 (WTF::WeakReference::WeakReference): WeakReference is just a void* now. 46 It's the caller's responsibility, when creating and getting, to use 47 a consistent storage type. We ensure a canonical storage type using a 48 typedef inside CanMakeWeakPtr. 49 50 (WTF::WeakPtr::WeakPtr): 51 (WTF::WeakPtr::get const): 52 (WTF::WeakPtr::operator bool const): 53 (WTF::WeakPtr::operator-> const): 54 (WTF::WeakPtr::operator* const): Adopted new WeakReference API. 55 56 (WTF::WeakPtrFactory::createWeakPtr const): No need for reinterpret_cast. 57 58 (WTF::weak_reference_cast): This isn't required for correctness, but it's 59 nice to show a complier error at WeakPtr construction sites when you know 60 that the types won't work. Otherwise, you get compiler errors at 61 dereference sites, which are slightly more mysterious ways of saying that 62 you constructed your WeakPtr incorrectly. 63 64 (WTF::WeakPtr<T>::WeakPtr): 65 (WTF::=): 66 (WTF::makeWeakPtr): 67 (WTF::weak_reference_upcast): Deleted. 68 (WTF::weak_reference_downcast): Deleted. 69 1 70 2019-05-27 Chris Dumez <cdumez@apple.com> 2 71 -
trunk/Source/WTF/wtf/WeakHashSet.h
r244815 r245857 33 33 namespace WTF { 34 34 35 template<> struct HashTraits<Ref<WeakReference>> : RefHashTraits<WeakReference> { 36 static const bool hasIsReleasedWeakValueFunction = true; 37 static bool isReleasedWeakValue(const Ref<WeakReference>& value) 38 { 39 return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get(); 40 } 41 }; 42 35 43 template <typename T> 36 44 class WeakHashSet { 37 45 public: 38 typedef HashSet<Ref<WeakReference <T>>> WeakReferenceSet;46 typedef HashSet<Ref<WeakReference>> WeakReferenceSet; 39 47 40 48 class WeakHashSetConstIterator : public std::iterator<std::forward_iterator_tag, T, std::ptrdiff_t, const T*, const T&> { … … 47 55 48 56 public: 49 T* get() const { return m_position->get(). get(); }57 T* get() const { return m_position->get().template get<T, typename T::WeakValueType>(); } 50 58 T& operator*() const { return *get(); } 51 59 T* operator->() const { return get(); } … … 61 69 void skipEmptyBuckets() 62 70 { 63 while (m_position != m_endPosition && ! m_position->get().get())71 while (m_position != m_endPosition && !get()) 64 72 ++m_position; 65 73 } … … 97 105 bool remove(const U& value) 98 106 { 99 auto * weakReference = weak_reference_downcast<T>(value.weakPtrFactory().m_ref.get());100 if (!weakReference )107 auto& weakReference = value.weakPtrFactory().m_ref; 108 if (!weakReference || !*weakReference) 101 109 return false; 102 return m_set.remove( weakReference);110 return m_set.remove(*weakReference); 103 111 } 104 112 … … 106 114 bool contains(const U& value) const 107 115 { 108 auto * weakReference = weak_reference_downcast<T>(value.weakPtrFactory().m_ref.get());109 if (!weakReference )116 auto& weakReference = value.weakPtrFactory().m_ref; 117 if (!weakReference || !*weakReference) 110 118 return false; 111 return m_set.contains( weakReference);119 return m_set.contains(*weakReference); 112 120 } 113 121 114 122 unsigned capacity() const { return m_set.capacity(); } 115 123 116 bool computesEmpty() const 117 { 118 if (m_set.isEmpty()) 119 return true; 120 for (auto& value : m_set) { 121 if (value->get()) 122 return false; 123 } 124 return true; 125 } 124 bool computesEmpty() const { return begin() == end(); } 126 125 127 126 bool hasNullReferences() const 128 127 { 129 return WTF::anyOf(m_set, [] (auto& value) { return !value ->get(); });128 return WTF::anyOf(m_set, [] (auto& value) { return !value.get(); }); 130 129 } 131 130 132 131 unsigned computeSize() const 133 132 { 134 const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value ->get(); });133 const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value.get(); }); 135 134 return m_set.size(); 136 135 } … … 146 145 }; 147 146 148 template<typename T> struct HashTraits<Ref<WeakReference<T>>> : RefHashTraits<WeakReference<T>> {149 static const bool hasIsReleasedWeakValueFunction = true;150 static bool isReleasedWeakValue(const Ref<WeakReference<T>>& value)151 {152 return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get().get();153 }154 };155 156 147 } // namespace WTF 157 148 -
trunk/Source/WTF/wtf/WeakPtr.h
r243965 r245857 34 34 namespace WTF { 35 35 36 // Testing interface for TestWebKitAPI 37 #ifndef DID_CREATE_WEAK_REFERENCE 38 #define DID_CREATE_WEAK_REFERENCE(p) 39 #endif 40 #ifndef WILL_DESTROY_WEAK_REFERENCE 41 #define WILL_DESTROY_WEAK_REFERENCE(p) 42 #endif 43 36 44 template<typename> class WeakHashSet; 37 45 template<typename> class WeakPtr; … … 39 47 40 48 // Note: WeakReference is an implementation detail, and should not be used directly. 41 template<typename T> 42 class WeakReference : public ThreadSafeRefCounted<WeakReference<T>> { 43 WTF_MAKE_NONCOPYABLE(WeakReference<T>); 49 class WeakReference : public ThreadSafeRefCounted<WeakReference> { 50 WTF_MAKE_NONCOPYABLE(WeakReference); 44 51 WTF_MAKE_FAST_ALLOCATED; 45 52 public: 46 ~WeakReference() { } // So that we can use a template specialization for testing purposes to detect leaks. 47 48 T* get() const { return m_ptr; } 53 template<typename T> static Ref<WeakReference> create(T* ptr) { return adoptRef(*new WeakReference(ptr)); } 54 55 ~WeakReference() 56 { 57 WILL_DESTROY_WEAK_REFERENCE(m_ptr); 58 } 59 60 template<typename T, typename WeakValueType> T* get() const { return static_cast<T*>(static_cast<WeakValueType*>(m_ptr)); } 61 explicit operator bool() const { return m_ptr; } 49 62 50 63 void clear() { m_ptr = nullptr; } 51 64 52 65 private: 53 friend class WeakPtr<T>; 54 friend class WeakPtrFactory<T>; 55 56 static Ref<WeakReference<T>> create(T* ptr) { return adoptRef(*new WeakReference(ptr)); } 57 58 explicit WeakReference(T* ptr) 66 template<typename T> explicit WeakReference(T* ptr) 59 67 : m_ptr(ptr) 60 68 { 61 } 62 63 T* m_ptr; 69 DID_CREATE_WEAK_REFERENCE(ptr); 70 } 71 72 void* m_ptr; 64 73 }; 65 74 … … 70 79 WeakPtr() { } 71 80 WeakPtr(std::nullptr_t) { } 72 WeakPtr(Ref<WeakReference<T>>&& ref) : m_ref(std::forward<Ref<WeakReference<T>>>(ref)) { }73 81 template<typename U> WeakPtr(const WeakPtr<U>&); 74 82 template<typename U> WeakPtr(WeakPtr<U>&&); 75 83 76 T* get() const { return m_ref ? m_ref-> get() : nullptr; }77 explicit operator bool() const { return m_ref && m_ref->get(); }84 T* get() const { return m_ref ? m_ref->template get<T, typename T::WeakValueType>() : nullptr; } 85 explicit operator bool() const { return m_ref && *m_ref; } 78 86 79 87 WeakPtr& operator=(std::nullptr_t) { m_ref = nullptr; return *this; } … … 81 89 template<typename U> WeakPtr& operator=(WeakPtr<U>&&); 82 90 83 T* operator->() const { return m_ref->get(); }84 T& operator*() const { return * m_ref->get(); }91 T* operator->() const { return get(); } 92 T& operator*() const { return *get(); } 85 93 86 94 void clear() { m_ref = nullptr; } 87 95 88 96 private: 97 explicit WeakPtr(Ref<WeakReference>&& ref) : m_ref(std::move(ref)) { } 89 98 template<typename> friend class WeakHashSet; 90 99 template<typename> friend class WeakPtr; 100 template<typename> friend class WeakPtrFactory; 91 101 template<typename U> friend WeakPtr<U> makeWeakPtr(U&); 92 102 93 RefPtr<WeakReference <T>> m_ref;103 RefPtr<WeakReference> m_ref; 94 104 }; 95 105 … … 111 121 { 112 122 if (!m_ref) 113 m_ref = WeakReference <T>::create(&ptr);114 return { makeRef(*m_ref) };123 m_ref = WeakReference::create(&ptr); 124 return WeakPtr<T>(makeRef(*m_ref)); 115 125 } 116 126 … … 118 128 { 119 129 if (!m_ref) 120 m_ref = WeakReference <T>::create(const_cast<T*>(&ptr));121 return { makeRef(reinterpret_cast<WeakReference<const T>&>(*m_ref)) };130 m_ref = WeakReference::create(const_cast<T*>(&ptr)); 131 return WeakPtr<T>(makeRef(*m_ref)); 122 132 } 123 133 … … 134 144 template<typename> friend class WeakHashSet; 135 145 136 mutable RefPtr<WeakReference <T>> m_ref;146 mutable RefPtr<WeakReference> m_ref; 137 147 }; 138 148 139 149 template<typename T> class CanMakeWeakPtr { 140 150 public: 151 typedef T WeakValueType; 152 141 153 const WeakPtrFactory<T>& weakPtrFactory() const { return m_weakFactory; } 142 154 WeakPtrFactory<T>& weakPtrFactory() { return m_weakFactory; } … … 146 158 }; 147 159 148 template<typename T, typename U> inline WeakReference<T>* weak_reference_upcast(WeakReference<U>* weakReference) 149 { 150 static_assert(std::is_convertible<U*, T*>::value, "U* must be convertible to T*"); 151 return reinterpret_cast<WeakReference<T>*>(weakReference); 152 } 153 154 template<typename T, typename U> inline WeakReference<T>* weak_reference_downcast(WeakReference<U>* weakReference) 155 { 156 static_assert(std::is_convertible<T*, U*>::value, "T* must be convertible to U*"); 157 return reinterpret_cast<WeakReference<T>*>(weakReference); 160 template<typename T, typename U> inline WeakReference* weak_reference_cast(WeakReference* weakReference) 161 { 162 UNUSED_VARIABLE(static_cast<T*>(static_cast<typename U::WeakValueType*>(nullptr))); // Verify that casting is valid. 163 return weakReference; 158 164 } 159 165 160 166 template<typename T> template<typename U> inline WeakPtr<T>::WeakPtr(const WeakPtr<U>& o) 161 : m_ref(weak_reference_ upcast<T>(o.m_ref.get()))167 : m_ref(weak_reference_cast<T, U>(o.m_ref.get())) 162 168 { 163 169 } 164 170 165 171 template<typename T> template<typename U> inline WeakPtr<T>::WeakPtr(WeakPtr<U>&& o) 166 : m_ref(adoptRef(weak_reference_ upcast<T>(o.m_ref.leakRef())))172 : m_ref(adoptRef(weak_reference_cast<T, U>(o.m_ref.leakRef()))) 167 173 { 168 174 } … … 170 176 template<typename T> template<typename U> inline WeakPtr<T>& WeakPtr<T>::operator=(const WeakPtr<U>& o) 171 177 { 172 m_ref = weak_reference_ upcast<T>(o.m_ref.get());178 m_ref = weak_reference_cast<T, U>(o.m_ref.get()); 173 179 return *this; 174 180 } … … 176 182 template<typename T> template<typename U> inline WeakPtr<T>& WeakPtr<T>::operator=(WeakPtr<U>&& o) 177 183 { 178 m_ref = adoptRef(weak_reference_ upcast<T>(o.m_ref.leakRef()));184 m_ref = adoptRef(weak_reference_cast<T, U>(o.m_ref.leakRef())); 179 185 return *this; 180 186 } … … 182 188 template<typename T> inline WeakPtr<T> makeWeakPtr(T& ref) 183 189 { 184 return { adoptRef(*weak_reference_downcast<T>(ref.weakPtrFactory().createWeakPtr(ref).m_ref.leakRef())) };190 return { ref.weakPtrFactory().createWeakPtr(ref) }; 185 191 } 186 192 -
trunk/Source/WebCore/ChangeLog
r245854 r245857 1 2019-05-28 Geoffrey Garen <ggaren@apple.com> 2 3 WeakPtr breaks vtables when upcasting to base classes 4 https://bugs.webkit.org/show_bug.cgi?id=188799 5 6 Reviewed by Youenn Fablet. 7 8 * Modules/encryptedmedia/MediaKeySession.cpp: 9 (WebCore::MediaKeySession::MediaKeySession): 10 * Modules/encryptedmedia/MediaKeySession.h: Adopted modern WeakPtr APIs. 11 Removed redundant WeakPtrFactory. 12 13 * css/CSSFontFace.cpp: 14 (WebCore::CSSFontFace::existingWrapper): 15 * css/CSSFontFace.h: Moved functions out of line to avoid #include 16 explosion for .get(). 17 18 * dom/ContainerNode.h: 19 * dom/Document.h: 20 * dom/Element.h: Moved CanMakeWeakPtr to ContainerNode because all 21 subclasses except for DocumentFragment were already so, and we have 22 code that uses WeakPtr<ContainerNode>, which, now that WeakPtr is 23 type-safe, is awkward to do when ContainerNode isn't CanMakeWeakPtr. 24 25 * dom/FullscreenManager.cpp: 26 (WebCore::FullscreenManager::fullscreenRenderer const): 27 * dom/FullscreenManager.h: 28 (WebCore::FullscreenManager::fullscreenRenderer const): Deleted. 29 * html/FormAssociatedElement.cpp: 30 (WebCore::FormAssociatedElement::form const): 31 * html/FormAssociatedElement.h: 32 (WebCore::FormAssociatedElement::form const): Deleted. Moved functions 33 out of line to avoid #include explosion for .get(). 34 35 * html/HTMLMediaElement.h: It takes an extra using declaration 36 to disambiguate multiple CanMakeWeakPtr base classes now. 37 38 * loader/MediaResourceLoader.cpp: 39 (WebCore::MediaResourceLoader::requestResource): Removed redundant .get(). 40 41 * page/DOMWindowProperty.cpp: 42 (WebCore::DOMWindowProperty::window const): 43 * page/DOMWindowProperty.h: 44 (WebCore::DOMWindowProperty::window const): Deleted. 45 * page/FrameViewLayoutContext.cpp: 46 (WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): 47 * page/FrameViewLayoutContext.h: 48 (WebCore::FrameViewLayoutContext::subtreeLayoutRoot const): Deleted. 49 * page/UndoItem.cpp: 50 (WebCore::UndoItem::undoManager const): 51 * page/UndoItem.h: 52 (WebCore::UndoItem::undoManager const): Deleted. Moved functions out of 53 line to avoid #include explosion for .get(). 54 55 * platform/ScrollView.h: It takes an extra using declaration 56 to disambiguate multiple CanMakeWeakPtr base classes now. 57 58 * platform/Widget.cpp: 59 (WebCore::Widget::parent const): 60 * platform/Widget.h: 61 (WebCore::Widget::parent const): Deleted. Moved functions out of line to avoid #include 62 explosion for .get(). 63 64 * platform/encryptedmedia/CDMInstanceSession.h: Made 65 CDMInstanceSessionClient CanMakeWeakPtr because we use WeakPtr<CDMInstanceSessionClient>. 66 67 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 68 CanMakeWeakPtr is inherited now. 69 70 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 71 (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC): 72 (WebCore::MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC): 73 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 74 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): Deleted. 75 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr): Deleted. 76 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 77 (WebCore::CMTimebaseEffectiveRateChangedCallback): 78 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC): 79 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): 80 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): 81 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance): 82 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged): 83 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cdmSession const): 84 * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: 85 * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: 86 (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): 87 (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): 88 (WebCore::SourceBufferPrivateAVFObjC::setCDMSession): 89 (WebCore::SourceBufferPrivateAVFObjC::flushVideo): 90 (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): 91 (WebCore::SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples): 92 (WebCore::SourceBufferPrivateAVFObjC::setVideoLayer): 93 (WebCore::SourceBufferPrivateAVFObjC::setDecompressionSession): Modernized WeakPtr API usage. 94 95 * rendering/RenderBlockFlow.cpp: 96 (WebCore::RenderBlockFlow::multiColumnFlowSlowCase const): 97 * rendering/RenderBlockFlow.h: 98 (WebCore::RenderBlockFlow::multiColumnFlow const): 99 * rendering/RenderMultiColumnFlow.cpp: 100 (WebCore::RenderMultiColumnFlow::findColumnSpannerPlaceholder const): 101 * rendering/RenderMultiColumnFlow.h: 102 * rendering/RenderTable.cpp: 103 (WebCore::RenderTable::header const): 104 (WebCore::RenderTable::footer const): 105 (WebCore::RenderTable::firstBody const): 106 (WebCore::RenderTable::topSection const): 107 * rendering/RenderTable.h: 108 (WebCore::RenderTable::header const): Deleted. 109 (WebCore::RenderTable::footer const): Deleted. 110 (WebCore::RenderTable::firstBody const): Deleted. 111 (WebCore::RenderTable::topSection const): Deleted. Moved functions out 112 of line to avoid #include explosion for .get(). 113 1 114 2019-05-29 Antti Koivisto <antti@apple.com> 2 115 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
r243887 r245857 95 95 UNUSED_PARAM(m_uninitialized); 96 96 97 m_instanceSession->setClient(m _cdmInstanceSessionClientWeakPtrFactory.createWeakPtr(*this));97 m_instanceSession->setClient(makeWeakPtr(*this)); 98 98 } 99 99 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
r243887 r245857 53 53 class SharedBuffer; 54 54 55 class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public C anMakeWeakPtr<MediaKeySession>, public CDMInstanceSessionClient {55 class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CDMInstanceSessionClient { 56 56 WTF_MAKE_ISO_ALLOCATED(MediaKeySession); 57 57 public: … … 121 121 double m_latestDecryptTime { 0 }; 122 122 Vector<std::pair<Ref<SharedBuffer>, MediaKeyStatus>> m_statuses; 123 WeakPtrFactory<CDMInstanceSessionClient> m_cdmInstanceSessionClientWeakPtrFactory;124 123 }; 125 124 -
trunk/Source/WebCore/css/CSSFontFace.cpp
r245190 r245857 123 123 } 124 124 125 FontFace* CSSFontFace::existingWrapper() 126 { 127 return m_wrapper.get(); 128 } 129 125 130 static FontSelectionRange calculateWeightRange(CSSValue& value) 126 131 { -
trunk/Source/WebCore/css/CSSFontFace.h
r243828 r245857 151 151 Ref<FontFace> wrapper(); 152 152 void setWrapper(FontFace&); 153 FontFace* existingWrapper() { return m_wrapper.get(); }153 FontFace* existingWrapper(); 154 154 155 155 struct FontLoadTiming { -
trunk/Source/WebCore/css/parser/CSSDeferredParser.cpp
r232613 r245857 40 40 } 41 41 42 StyleSheetContents* CSSDeferredParser::styleSheet() const 43 { 44 return m_styleSheet.get(); 45 } 46 42 47 Ref<ImmutableStyleProperties> CSSDeferredParser::parseDeclaration(const CSSParserTokenRange& range) 43 48 { -
trunk/Source/WebCore/css/parser/CSSDeferredParser.h
r233520 r245857 48 48 49 49 const CSSParserContext& context() const { return m_context; } 50 StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }50 StyleSheetContents* styleSheet() const; 51 51 52 52 Ref<ImmutableStyleProperties> parseDeclaration(const CSSParserTokenRange&); -
trunk/Source/WebCore/dom/ContainerNode.h
r235780 r245857 26 26 #include "CollectionType.h" 27 27 #include "Node.h" 28 #include <wtf/WeakPtr.h> 28 29 29 30 namespace WebCore { … … 36 37 typedef Vector<Ref<Node>, initialNodeVectorSize> NodeVector; 37 38 38 class ContainerNode : public Node {39 class ContainerNode : public CanMakeWeakPtr<ContainerNode>, public Node { 39 40 WTF_MAKE_ISO_ALLOCATED(ContainerNode); 40 41 public: -
trunk/Source/WebCore/dom/Document.h
r245796 r245857 348 348 , public ScriptExecutionContext 349 349 , public FontSelectorClient 350 , public CanMakeWeakPtr<Document>351 350 , public FrameDestructionObserver 352 351 , public Supplementable<Document> -
trunk/Source/WebCore/dom/Element.h
r245642 r245857 78 78 #endif 79 79 80 class Element : public ContainerNode , public CanMakeWeakPtr<Element>{80 class Element : public ContainerNode { 81 81 WTF_MAKE_ISO_ALLOCATED(Element); 82 82 public: -
trunk/Source/WebCore/dom/FullscreenManager.cpp
r244440 r245857 440 440 } 441 441 442 RenderFullScreen* FullscreenManager::fullscreenRenderer() const 443 { 444 return m_fullscreenRenderer.get(); 445 } 446 442 447 void FullscreenManager::dispatchFullscreenChangeEvents() 443 448 { -
trunk/Source/WebCore/dom/FullscreenManager.h
r244440 r245857 80 80 81 81 void setFullscreenRenderer(RenderTreeBuilder&, RenderFullScreen&); 82 RenderFullScreen* fullscreenRenderer() const { return m_fullscreenRenderer.get(); }82 RenderFullScreen* fullscreenRenderer() const; 83 83 84 84 void dispatchFullscreenChangeEvents(); -
trunk/Source/WebCore/html/FormAssociatedElement.cpp
r243954 r245857 120 120 } 121 121 122 HTMLFormElement* FormAssociatedElement::form() const 123 { 124 return m_form.get(); 125 } 126 122 127 void FormAssociatedElement::formOwnerRemovedFromTree(const Node& formRoot) 123 128 { -
trunk/Source/WebCore/html/FormAssociatedElement.h
r243954 r245857 49 49 50 50 static HTMLFormElement* findAssociatedForm(const HTMLElement*, HTMLFormElement*); 51 HTMLFormElement* form() const { return m_form.get(); }51 WEBCORE_EXPORT HTMLFormElement* form() const; 52 52 ValidityState* validity(); 53 53 -
trunk/Source/WebCore/html/HTMLMediaElement.h
r245712 r245857 150 150 WTF_MAKE_ISO_ALLOCATED(HTMLMediaElement); 151 151 public: 152 typedef HTMLElement::WeakValueType WeakValueType; 153 using HTMLElement::weakPtrFactory; 154 152 155 RefPtr<MediaPlayer> player() const { return m_player; } 153 156 … … 575 578 576 579 enum class AutoplayEventPlaybackState { None, PreventedAutoplay, StartedWithUserGesture, StartedWithoutUserGesture }; 577 578 using HTMLElement::weakPtrFactory;579 580 580 581 protected: -
trunk/Source/WebCore/loader/MediaResourceLoader.cpp
r243459 r245857 98 98 auto cachedRequest = createPotentialAccessControlRequest(WTFMove(request), *m_document, m_crossOriginMode, WTFMove(loaderOptions)); 99 99 if (m_mediaElement) 100 cachedRequest.setInitiator(*m_mediaElement .get());100 cachedRequest.setInitiator(*m_mediaElement); 101 101 102 102 auto resource = m_document->cachedResourceLoader().requestMedia(WTFMove(cachedRequest)).value_or(nullptr); -
trunk/Source/WebCore/page/DOMWindowProperty.cpp
r242676 r245857 43 43 } 44 44 45 DOMWindow* DOMWindowProperty::window() const 46 { 47 return m_window.get(); 45 48 } 49 50 } -
trunk/Source/WebCore/page/DOMWindowProperty.h
r242676 r245857 36 36 public: 37 37 Frame* frame() const; 38 DOMWindow* window() const { return m_window.get(); }38 DOMWindow* window() const; 39 39 40 40 protected: -
trunk/Source/WebCore/page/FrameViewLayoutContext.cpp
r245838 r245857 459 459 } 460 460 461 RenderElement* FrameViewLayoutContext::subtreeLayoutRoot() const 462 { 463 return m_subtreeLayoutRoot.get(); 464 } 465 461 466 void FrameViewLayoutContext::convertSubtreeLayoutToFullLayout() 462 467 { -
trunk/Source/WebCore/page/FrameViewLayoutContext.h
r240968 r245857 28 28 #include "LayoutUnit.h" 29 29 #include "Timer.h" 30 31 30 #include <wtf/WeakPtr.h> 32 31 … … 83 82 unsigned layoutCount() const { return m_layoutCount; } 84 83 85 RenderElement* subtreeLayoutRoot() const { return m_subtreeLayoutRoot.get(); }84 RenderElement* subtreeLayoutRoot() const; 86 85 void clearSubtreeLayoutRoot() { m_subtreeLayoutRoot.clear(); } 87 86 void convertSubtreeLayoutToFullLayout(); -
trunk/Source/WebCore/page/UndoItem.cpp
r240315 r245857 34 34 WTF_MAKE_ISO_ALLOCATED_IMPL(UndoItem); 35 35 36 UndoManager* UndoItem::undoManager() const 37 { 38 return m_undoManager.get(); 39 } 40 36 41 void UndoItem::setUndoManager(UndoManager* undoManager) 37 42 { -
trunk/Source/WebCore/page/UndoItem.h
r240476 r245857 56 56 Document* document() const; 57 57 58 UndoManager* undoManager() const { return m_undoManager.get(); }58 UndoManager* undoManager() const; 59 59 void setUndoManager(UndoManager*); 60 60 -
trunk/Source/WebCore/platform/ScrollView.h
r245320 r245857 66 66 virtual ~ScrollView(); 67 67 68 typedef Widget::WeakValueType WeakValueType; 69 using Widget::weakPtrFactory; 70 68 71 // ScrollableArea functions. 69 72 int scrollSize(ScrollbarOrientation) const final; … … 74 77 75 78 virtual void notifyPageThatContentAreaWillPaint() const; 76 77 using Widget::weakPtrFactory;78 79 79 80 IntPoint locationOfContents() const; -
trunk/Source/WebCore/platform/Widget.cpp
r245320 r245857 43 43 } 44 44 45 ScrollView* Widget::parent() const 46 { 47 return m_parent.get(); 48 } 49 45 50 void Widget::setParent(ScrollView* view) 46 51 { -
trunk/Source/WebCore/platform/Widget.h
r245320 r245857 141 141 WEBCORE_EXPORT void removeFromParent(); 142 142 WEBCORE_EXPORT virtual void setParent(ScrollView* view); 143 ScrollView* parent() const { return m_parent.get(); }143 WEBCORE_EXPORT ScrollView* parent() const; 144 144 FrameView* root() const; 145 145 -
trunk/Source/WebCore/platform/encryptedmedia/CDMInstanceSession.h
r240746 r245857 40 40 class SharedBuffer; 41 41 42 class CDMInstanceSessionClient {42 class CDMInstanceSessionClient : public CanMakeWeakPtr<CDMInstanceSessionClient> { 43 43 public: 44 44 virtual ~CDMInstanceSessionClient() = default; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r245039 r245857 338 338 void setShouldObserveTimeControlStatus(bool); 339 339 340 WeakPtrFactory<MediaPlayerPrivateAVFoundationObjC> m_weakPtrFactory;341 340 RetainPtr<AVURLAsset> m_avAsset; 342 341 RetainPtr<AVPlayer> m_avPlayer; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r245701 r245857 360 360 , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManagerObjC>()) 361 361 , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect) 362 , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:m _weakPtrFactory.createWeakPtr(*this)]))362 , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:makeWeakPtr(*this)])) 363 363 , m_videoFrameHasDrawn(false) 364 364 , m_haveCheckedPlayability(false) 365 365 #if HAVE(AVFOUNDATION_VIDEO_OUTPUT) 366 , m_videoOutputDelegate(adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:m _weakPtrFactory.createWeakPtr(*this)]))366 , m_videoOutputDelegate(adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:makeWeakPtr(*this)])) 367 367 #endif 368 368 #if HAVE(AVFOUNDATION_LOADER_DELEGATE) 369 , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithPlayer:m _weakPtrFactory.createWeakPtr(*this)]))369 , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithPlayer:makeWeakPtr(*this)])) 370 370 #endif 371 371 , m_currentTextTrack(0) … … 388 388 MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC() 389 389 { 390 m_weakPtrFactory.revokeAll();390 weakPtrFactory().revokeAll(); 391 391 392 392 #if HAVE(AVFOUNDATION_LOADER_DELEGATE) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r242720 r245857 60 60 61 61 class MediaPlayerPrivateMediaSourceAVFObjC 62 : public MediaPlayerPrivateInterface 62 : public CanMakeWeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> 63 , public MediaPlayerPrivateInterface 63 64 #if !RELEASE_LOG_DISABLED 64 65 , private LoggerHelper … … 122 123 #endif 123 124 void setCDMSession(LegacyCDMSession*) override; 124 CDMSessionMediaSourceAVFObjC* cdmSession() const { return m_session.get(); }125 CDMSessionMediaSourceAVFObjC* cdmSession() const; 125 126 #endif 126 127 … … 147 148 const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const; 148 149 bool shouldCheckHardwareSupport() const; 149 150 WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }151 150 152 151 #if !RELEASE_LOG_DISABLED … … 283 282 284 283 MediaPlayer* m_player; 285 WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_weakPtrFactory;286 284 WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_sizeChangeObserverWeakPtrFactory; 287 285 RefPtr<MediaSourcePrivateAVFObjC> m_mediaSourcePrivate; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r244980 r245857 53 53 #import <wtf/MainThread.h> 54 54 #import <wtf/NeverDestroyed.h> 55 #import <wtf/WeakPtr.h> 55 56 56 57 #import "CoreVideoSoftLink.h" … … 88 89 { 89 90 MediaPlayerPrivateMediaSourceAVFObjC* player = (MediaPlayerPrivateMediaSourceAVFObjC*)const_cast<void*>(listener); 90 callOnMainThread([weakThis = player->createWeakPtr()] {91 callOnMainThread([weakThis = makeWeakPtr(player)] { 91 92 if (!weakThis) 92 93 return; 93 weakThis .get()->effectiveRateChanged();94 weakThis->effectiveRateChanged(); 94 95 }); 95 96 } … … 121 122 // addPeriodicTimeObserverForInterval: throws an exception if you pass a non-numeric CMTime, so just use 122 123 // an arbitrarily large time value of once an hour: 123 __block auto weakThis = createWeakPtr();124 __block auto weakThis = makeWeakPtr(*this); 124 125 m_timeJumpedObserver = [m_synchronizer addPeriodicTimeObserverForInterval:PAL::toCMTime(MediaTime::createWithDouble(3600)) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) { 125 126 #if LOG_DISABLED … … 287 288 { 288 289 ALWAYS_LOG(LOGIDENTIFIER); 289 callOnMainThread([weakThis = createWeakPtr()] {290 callOnMainThread([weakThis = makeWeakPtr(*this)] { 290 291 if (!weakThis) 291 292 return; … … 308 309 { 309 310 ALWAYS_LOG(LOGIDENTIFIER); 310 callOnMainThread([weakThis = createWeakPtr()] {311 callOnMainThread([weakThis = makeWeakPtr(*this)] { 311 312 if (!weakThis) 312 313 return; … … 408 409 409 410 m_seeking = true; 410 auto weakThis = createWeakPtr();411 411 m_pendingSeek = std::make_unique<PendingSeek>(time, negativeThreshold, positiveThreshold); 412 412 … … 859 859 860 860 MediaTime duration = m_mediaSourcePrivate->duration(); 861 auto weakThis = createWeakPtr();862 861 NSArray* times = @[[NSValue valueWithCMTime:PAL::toCMTime(duration)]]; 863 862 … … 866 865 UNUSED_PARAM(logSiteIdentifier); 867 866 868 m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis , duration, logSiteIdentifier, this] {867 m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis = makeWeakPtr(*this), duration, logSiteIdentifier, this] { 869 868 if (!weakThis) 870 869 return; … … 956 955 #endif 957 956 957 CDMSessionMediaSourceAVFObjC* MediaPlayerPrivateMediaSourceAVFObjC::cdmSession() const 958 { 959 return m_session.get(); 960 } 961 958 962 void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(LegacyCDMSession* session) 959 963 { -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
r242720 r245857 176 176 ALLOW_NEW_API_WITHOUT_GUARDS_END 177 177 178 WeakPtr<SourceBufferPrivateAVFObjC> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }179 180 178 Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks; 181 179 Vector<RefPtr<AudioTrackPrivateMediaSourceAVFObjC>> m_audioTracks; 182 180 Vector<SourceBufferPrivateAVFObjCErrorClient*> m_errorClients; 183 181 184 WeakPtrFactory<SourceBufferPrivateAVFObjC> m_weakFactory;185 182 WeakPtrFactory<SourceBufferPrivateAVFObjC> m_appendWeakFactory; 186 183 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
r244716 r245857 466 466 SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent) 467 467 : m_parser(adoptNS([PAL::allocAVStreamDataParserInstance() init])) 468 , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent: createWeakPtr()]))469 , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent: createWeakPtr()]))468 , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:makeWeakPtr(*this)])) 469 , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:makeWeakPtr(*this)])) 470 470 , m_isAppendingGroup(adoptOSObject(dispatch_group_create())) 471 471 , m_mediaSource(parent) … … 885 885 if (!m_audioRenderers.contains(trackID)) { 886 886 renderer = adoptNS([PAL::allocAVSampleBufferAudioRendererInstance() init]); 887 auto weakThis = createWeakPtr();887 auto weakThis = makeWeakPtr(*this); 888 888 [renderer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{ 889 889 if (weakThis) … … 921 921 922 922 if (m_hdcpError) { 923 WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr(); 924 callOnMainThread([weakThis] { 923 callOnMainThread([weakThis = makeWeakPtr(*this)] { 925 924 if (!weakThis || !weakThis->m_session || !weakThis->m_hdcpError) 926 925 return; … … 1066 1065 if (m_decompressionSession) { 1067 1066 m_decompressionSession->flush(); 1068 m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = createWeakPtr()] {1067 m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = makeWeakPtr(*this)] { 1069 1068 if (weakThis && weakThis->m_mediaSource) 1070 1069 weakThis->m_mediaSource->player()->setHasAvailableVideoFrame(true); … … 1139 1138 } else { 1140 1139 [m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer]; 1141 [m_displayLayer prerollDecodeWithCompletionHandler:[weakThis = createWeakPtr()] (BOOL success) mutable {1140 [m_displayLayer prerollDecodeWithCompletionHandler:[weakThis = makeWeakPtr(*this)] (BOOL success) mutable { 1142 1141 if (!success || !weakThis) 1143 1142 return; … … 1238 1237 } 1239 1238 if (m_displayLayer) { 1240 auto weakThis = createWeakPtr();1239 auto weakThis = makeWeakPtr(*this); 1241 1240 [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ { 1242 1241 if (weakThis) … … 1245 1244 } 1246 1245 } else if (m_audioRenderers.contains(trackID)) { 1247 auto weakThis = createWeakPtr();1246 auto weakThis = makeWeakPtr(*this); 1248 1247 [m_audioRenderers.get(trackID) requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ { 1249 1248 if (weakThis) … … 1279 1278 1280 1279 if (m_displayLayer) { 1281 auto weakThis = createWeakPtr();1280 auto weakThis = makeWeakPtr(*this); 1282 1281 [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ { 1283 1282 if (weakThis) … … 1307 1306 return; 1308 1307 1309 WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr(); 1310 m_decompressionSession->requestMediaDataWhenReady([weakThis] { 1308 m_decompressionSession->requestMediaDataWhenReady([weakThis = makeWeakPtr(*this)] { 1311 1309 if (weakThis) 1312 1310 weakThis->didBecomeReadyForMoreSamples(weakThis->m_enabledVideoTrackID); 1313 1311 }); 1314 m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = createWeakPtr()] {1312 m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = makeWeakPtr(*this)] { 1315 1313 if (weakThis && weakThis->m_mediaSource) 1316 1314 weakThis->m_mediaSource->player()->setHasAvailableVideoFrame(true); -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r245838 r245857 160 160 } 161 161 162 RenderMultiColumnFlow* RenderBlockFlow::multiColumnFlowSlowCase() const 163 { 164 return rareBlockFlowData()->m_multiColumnFlow.get(); 165 } 166 162 167 RenderBlockFlow* RenderBlockFlow::previousSiblingWithOverhangingFloats(bool& parentHasFloats) const 163 168 { -
trunk/Source/WebCore/rendering/RenderBlockFlow.h
r245838 r245857 265 265 void layoutLineGridBox(); 266 266 267 RenderMultiColumnFlow* multiColumnFlow() const { return hasRareBlockFlowData() ? rareBlockFlowData()->m_multiColumnFlow.get() : nullptr; } 267 RenderMultiColumnFlow* multiColumnFlow() const { return hasRareBlockFlowData() ? multiColumnFlowSlowCase() : nullptr; } 268 RenderMultiColumnFlow* multiColumnFlowSlowCase() const; 268 269 void setMultiColumnFlow(RenderMultiColumnFlow&); 269 270 void clearMultiColumnFlow(); -
trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp
r242919 r245857 108 108 } 109 109 110 RenderMultiColumnSpannerPlaceholder* RenderMultiColumnFlow::findColumnSpannerPlaceholder(RenderBox* spanner) const 111 { 112 return m_spannerMap->get(spanner).get(); 113 } 114 110 115 void RenderMultiColumnFlow::layout() 111 116 { -
trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h
r234215 r245857 49 49 static RenderBox* previousColumnSetOrSpannerSiblingOf(const RenderBox*); 50 50 51 RenderMultiColumnSpannerPlaceholder* findColumnSpannerPlaceholder(RenderBox* spanner) const { return m_spannerMap->get(spanner).get(); }51 RenderMultiColumnSpannerPlaceholder* findColumnSpannerPlaceholder(RenderBox* spanner) const; 52 52 53 53 void layout() override; -
trunk/Source/WebCore/rendering/RenderTable.cpp
r245543 r245857 96 96 97 97 RenderTable::~RenderTable() = default; 98 99 RenderTableSection* RenderTable::header() const 100 { 101 return m_head.get(); 102 } 103 104 RenderTableSection* RenderTable::footer() const 105 { 106 return m_foot.get(); 107 } 108 109 RenderTableSection* RenderTable::firstBody() const 110 { 111 return m_firstBody.get(); 112 } 113 114 RenderTableSection* RenderTable::topSection() const 115 { 116 ASSERT(!needsSectionRecalc()); 117 if (m_head) 118 return m_head.get(); 119 if (m_firstBody) 120 return m_firstBody.get(); 121 return m_foot.get(); 122 } 98 123 99 124 void RenderTable::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) -
trunk/Source/WebCore/rendering/RenderTable.h
r239427 r245857 153 153 } 154 154 155 RenderTableSection* header() const { return m_head.get(); }156 RenderTableSection* footer() const { return m_foot.get(); }157 RenderTableSection* firstBody() const { return m_firstBody.get(); }155 RenderTableSection* header() const; 156 RenderTableSection* footer() const; 157 RenderTableSection* firstBody() const; 158 158 159 159 // This function returns 0 if the table has no section. … … 371 371 }; 372 372 373 inline RenderTableSection* RenderTable::topSection() const374 {375 ASSERT(!needsSectionRecalc());376 if (m_head)377 return m_head.get();378 if (m_firstBody)379 return m_firstBody.get();380 return m_foot.get();381 }382 383 373 inline bool isDirectionSame(const RenderBox* tableItem, const RenderBox* otherTableItem) { return tableItem && otherTableItem ? tableItem->style().direction() == otherTableItem->style().direction() : true; } 384 374 -
trunk/Source/WebKit/ChangeLog
r245856 r245857 1 2019-05-28 Geoffrey Garen <ggaren@apple.com> 2 3 WeakPtr breaks vtables when upcasting to base classes 4 https://bugs.webkit.org/show_bug.cgi?id=188799 5 6 Reviewed by Youenn Fablet. 7 8 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 9 (WebKit::WebResourceLoadStatisticsStore::networkSession): 10 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 11 * Shared/WebBackForwardListItem.cpp: 12 (WebKit::WebBackForwardListItem::suspendedPage const): 13 * Shared/WebBackForwardListItem.h: 14 (WebKit::WebBackForwardListItem::suspendedPage const): Deleted. Moved 15 functions out of line to avoid #include explosion for .get(). 16 17 * UIProcess/Authentication/cocoa/SecKeyProxyStore.h: 18 (WebKit::SecKeyProxyStore::get const): 19 (WebKit::SecKeyProxyStore::weakPtrFactory const): Deleted. Adopted 20 CanMakeWeakPtr. 21 22 * UIProcess/WebAuthentication/AuthenticatorManager.h: 23 * UIProcess/WebProcessProxy.cpp: It takes an extra using declaration 24 to disambiguate multiple CanMakeWeakPtr base classes now. 25 26 (WebKit::WebProcessProxy::processPool const): 27 * UIProcess/WebProcessProxy.h: 28 (WebKit::WebProcessProxy::processPool const): Deleted. Moved 29 functions out of line to avoid #include explosion for .get(). 30 1 31 2019-05-29 Youenn Fablet <youenn@apple.com> 2 32 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r245796 r245857 1017 1017 } 1018 1018 1019 NetworkSession* WebResourceLoadStatisticsStore::networkSession() 1020 { 1021 return m_networkSession.get(); 1022 } 1023 1019 1024 void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domainsToRemoveWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler) 1020 1025 { -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r245796 r245857 176 176 void notifyResourceLoadStatisticsProcessed(); 177 177 178 NetworkSession* networkSession() { return m_networkSession.get(); }178 NetworkSession* networkSession(); 179 179 180 180 void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const; -
trunk/Source/WebKit/Shared/WebBackForwardListItem.cpp
r245796 r245857 169 169 } 170 170 171 SuspendedPageProxy* WebBackForwardListItem::suspendedPage() const 172 { 173 return m_suspendedPage.get(); 174 } 175 171 176 void WebBackForwardListItem::removeSuspendedPageFromProcessPool() 172 177 { -
trunk/Source/WebKit/Shared/WebBackForwardListItem.h
r245796 r245857 76 76 #endif 77 77 void setSuspendedPage(SuspendedPageProxy*); 78 SuspendedPageProxy* suspendedPage() const { return m_suspendedPage.get(); }78 SuspendedPageProxy* suspendedPage() const; 79 79 80 80 #if !LOG_DISABLED -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp
r243608 r245857 25 25 #include "WebKitURIRequest.h" 26 26 #include "WebKitWebResourcePrivate.h" 27 #include "WebPageProxy.h" 27 28 #include <glib/gi18n-lib.h> 28 29 #include <wtf/glib/GRefPtr.h> -
trunk/Source/WebKit/UIProcess/Authentication/cocoa/SecKeyProxyStore.h
r241658 r245857 40 40 namespace WebKit { 41 41 42 class SecKeyProxyStore : public RefCounted<SecKeyProxyStore> {42 class SecKeyProxyStore : public RefCounted<SecKeyProxyStore>, public CanMakeWeakPtr<SecKeyProxyStore> { 43 43 public: 44 44 static Ref<SecKeyProxyStore> create() { return adoptRef(* new SecKeyProxyStore()); } … … 48 48 49 49 auto* get() const { return m_secKeyProxy.get(); } 50 auto& weakPtrFactory() const { return m_weakPtrFactory; }51 50 52 51 private: 53 52 SecKeyProxyStore() = default; 54 53 55 WeakPtrFactory<SecKeyProxyStore> m_weakPtrFactory;56 54 RetainPtr<SecKeyProxy> m_secKeyProxy; 57 55 }; -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h
r245500 r245857 50 50 51 51 using AuthenticatorTransportService::Observer::weakPtrFactory; 52 typedef AuthenticatorTransportService::Observer::WeakValueType WeakValueType; 52 53 53 54 AuthenticatorManager(); -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r245796 r245857 1514 1514 } 1515 1515 1516 WebProcessPool& WebProcessProxy::processPool() const 1517 { 1518 ASSERT(m_processPool); 1519 return *m_processPool.get(); 1520 } 1521 1516 1522 #if PLATFORM(WATCHOS) 1517 1523 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r245796 r245857 120 120 void decrementSuspendedPageCount(); 121 121 122 WebProcessPool& processPool() const { ASSERT(m_processPool); return *m_processPool.get(); }122 WebProcessPool& processPool() const; 123 123 124 124 WebCore::RegistrableDomain registrableDomain() const { return m_registrableDomain.valueOr(WebCore::RegistrableDomain { }); } -
trunk/Tools/ChangeLog
r245851 r245857 1 2019-05-28 Geoffrey Garen <ggaren@apple.com> 2 3 WeakPtr breaks vtables when upcasting to base classes 4 https://bugs.webkit.org/show_bug.cgi?id=188799 5 6 Reviewed by Youenn Fablet. 7 8 * TestWebKitAPI/Tests/WTF/WeakPtr.cpp: Adopt the new macro API instead 9 of template specialization for observing weak references. 10 11 (TestWebKitAPI::Int::Int): 12 (TestWebKitAPI::Int::operator int const): 13 (TestWebKitAPI::Int::operator== const): Use a class for integer tests 14 because WeakPtr doesn't naturally support pointing to non-class objects 15 now. 16 17 (TestWebKitAPI::Base::foo): 18 (TestWebKitAPI::Derived::foo): Inherit from CanMakeWeakPtr to enable 19 deduction of the weak pointer type. 20 21 (TestWebKitAPI::TEST): Updated to use Int. 22 23 (TestWebKitAPI::Base::weakPtrFactory const): Deleted. 24 (WTF::WeakReference<TestWebKitAPI::Base>::WeakReference): Deleted. 25 (WTF::WeakReference<TestWebKitAPI::Base>::~WeakReference): Deleted. 26 1 27 2019-05-29 Aakash Jain <aakash_jain@apple.com> 2 28 -
trunk/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp
r243965 r245857 26 26 #include "config.h" 27 27 28 static unsigned s_baseWeakReferences = 0; 29 30 #define DID_CREATE_WEAK_REFERENCE(p) do { \ 31 ++s_baseWeakReferences; \ 32 } while (0); 33 34 #define WILL_DESTROY_WEAK_REFERENCE(p) do { \ 35 --s_baseWeakReferences; \ 36 } while (0); 37 28 38 #include "Test.h" 29 39 #include <wtf/HashSet.h> … … 31 41 #include <wtf/WeakPtr.h> 32 42 33 static unsigned s_baseWeakReferences = 0;34 35 43 namespace TestWebKitAPI { 36 44 37 class Base { 45 struct Int : public CanMakeWeakPtr<Int> { 46 Int(int i) : m_i(i) { } 47 operator int() const { return m_i; } 48 bool operator==(const Int& other) const { return m_i == other.m_i; } 49 int m_i; 50 }; 51 52 class Base : public CanMakeWeakPtr<Base> { 38 53 public: 39 54 Base() { } … … 44 59 } 45 60 46 auto& weakPtrFactory() const { return m_weakPtrFactory; } 47 48 private: 49 WeakPtrFactory<Base> m_weakPtrFactory; 61 int dummy; // Prevent empty base class optimization, to make testing more interesting. 50 62 }; 51 63 … … 54 66 Derived() { } 55 67 68 virtual ~Derived() { } // Force a pointer fixup when casting Base <-> Derived 69 56 70 int foo() 57 71 { … … 62 76 } 63 77 64 namespace WTF {65 66 template<>67 WeakReference<TestWebKitAPI::Base>::WeakReference(TestWebKitAPI::Base* ptr)68 : m_ptr(ptr)69 {70 ++s_baseWeakReferences;71 }72 template<>73 WeakReference<TestWebKitAPI::Base>::~WeakReference()74 {75 --s_baseWeakReferences;76 }77 78 }79 80 78 namespace TestWebKitAPI { 81 79 82 80 TEST(WTF_WeakPtr, Basic) 83 81 { 84 int dummy = 5;85 WeakPtrFactory< int>* factory = new WeakPtrFactory<int>();86 WeakPtr< int> weakPtr1 = factory->createWeakPtr(dummy);87 WeakPtr< int> weakPtr2 = factory->createWeakPtr(dummy);88 WeakPtr< int> weakPtr3 = factory->createWeakPtr(dummy);82 Int dummy(5); 83 WeakPtrFactory<Int>* factory = new WeakPtrFactory<Int>(); 84 WeakPtr<Int> weakPtr1 = factory->createWeakPtr(dummy); 85 WeakPtr<Int> weakPtr2 = factory->createWeakPtr(dummy); 86 WeakPtr<Int> weakPtr3 = factory->createWeakPtr(dummy); 89 87 EXPECT_EQ(weakPtr1.get(), &dummy); 90 88 EXPECT_EQ(weakPtr2.get(), &dummy); … … 107 105 TEST(WTF_WeakPtr, Assignment) 108 106 { 109 int dummy = 5;110 WeakPtr< int> weakPtr;111 { 112 WeakPtrFactory< int> factory;107 Int dummy(5); 108 WeakPtr<Int> weakPtr; 109 { 110 WeakPtrFactory<Int> factory; 113 111 EXPECT_NULL(weakPtr.get()); 114 112 weakPtr = factory.createWeakPtr(dummy); … … 120 118 TEST(WTF_WeakPtr, MultipleFactories) 121 119 { 122 int dummy1 = 5;123 int dummy2 = 7;124 WeakPtrFactory< int>* factory1 = new WeakPtrFactory<int>();125 WeakPtrFactory< int>* factory2 = new WeakPtrFactory<int>();126 WeakPtr< int> weakPtr1 = factory1->createWeakPtr(dummy1);127 WeakPtr< int> weakPtr2 = factory2->createWeakPtr(dummy2);120 Int dummy1(5); 121 Int dummy2(7); 122 WeakPtrFactory<Int>* factory1 = new WeakPtrFactory<Int>(); 123 WeakPtrFactory<Int>* factory2 = new WeakPtrFactory<Int>(); 124 WeakPtr<Int> weakPtr1 = factory1->createWeakPtr(dummy1); 125 WeakPtr<Int> weakPtr2 = factory2->createWeakPtr(dummy2); 128 126 EXPECT_EQ(weakPtr1.get(), &dummy1); 129 127 EXPECT_EQ(weakPtr2.get(), &dummy2); … … 140 138 TEST(WTF_WeakPtr, RevokeAll) 141 139 { 142 int dummy = 5;143 WeakPtrFactory< int> factory;144 WeakPtr< int> weakPtr1 = factory.createWeakPtr(dummy);145 WeakPtr< int> weakPtr2 = factory.createWeakPtr(dummy);146 WeakPtr< int> weakPtr3 = factory.createWeakPtr(dummy);140 Int dummy(5); 141 WeakPtrFactory<Int> factory; 142 WeakPtr<Int> weakPtr1 = factory.createWeakPtr(dummy); 143 WeakPtr<Int> weakPtr2 = factory.createWeakPtr(dummy); 144 WeakPtr<Int> weakPtr3 = factory.createWeakPtr(dummy); 147 145 EXPECT_EQ(weakPtr1.get(), &dummy); 148 146 EXPECT_EQ(weakPtr2.get(), &dummy); … … 154 152 } 155 153 156 struct Foo {154 struct Foo : public CanMakeWeakPtr<Foo> { 157 155 void bar() { }; 158 156 }; … … 186 184 TEST(WTF_WeakPtr, Forget) 187 185 { 188 int dummy = 5;189 int dummy2 = 7;190 191 WeakPtrFactory< int> outerFactory;192 WeakPtr< int> weakPtr1, weakPtr2, weakPtr3, weakPtr4;193 { 194 WeakPtrFactory< int> innerFactory;186 Int dummy(5); 187 Int dummy2(7); 188 189 WeakPtrFactory<Int> outerFactory; 190 WeakPtr<Int> weakPtr1, weakPtr2, weakPtr3, weakPtr4; 191 { 192 WeakPtrFactory<Int> innerFactory; 195 193 weakPtr1 = innerFactory.createWeakPtr(dummy); 196 194 weakPtr2 = innerFactory.createWeakPtr(dummy); … … 218 216 EXPECT_EQ(weakPtr4.get(), &dummy); 219 217 220 WeakPtr< int> weakPtr5 = weakPtr2;218 WeakPtr<Int> weakPtr5 = weakPtr2; 221 219 EXPECT_EQ(weakPtr2.get(), &dummy); 222 220 EXPECT_EQ(weakPtr5.get(), &dummy); … … 234 232 EXPECT_EQ(weakPtr4.get(), &dummy2); 235 233 236 WeakPtr< int> weakPtr5 = weakPtr4;234 WeakPtr<Int> weakPtr5 = weakPtr4; 237 235 EXPECT_EQ(weakPtr4.get(), &dummy2); 238 236 EXPECT_EQ(weakPtr5.get(), &dummy2); 239 237 weakPtr5.clear(); 240 238 EXPECT_NULL(weakPtr5.get()); 241 WeakPtr< int> weakPtr6 = weakPtr5;239 WeakPtr<Int> weakPtr6 = weakPtr5; 242 240 EXPECT_NULL(weakPtr6.get()); 243 241 EXPECT_EQ(weakPtr5.get(), weakPtr6.get()); 244 242 245 WeakPtr< int> weakPtr7 = outerFactory.createWeakPtr(dummy2);243 WeakPtr<Int> weakPtr7 = outerFactory.createWeakPtr(dummy2); 246 244 EXPECT_EQ(weakPtr7.get(), &dummy2); 247 245 weakPtr7 = nullptr; … … 251 249 TEST(WTF_WeakPtr, Downcasting) 252 250 { 253 int dummy0 = 0;254 int dummy1 = 1;251 int dummy0(0); 252 int dummy1(1); 255 253 256 254 WeakPtr<Base> baseWeakPtr;
Note:
See TracChangeset
for help on using the changeset viewer.