Unreviewed, rolling out r245857.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 May 2019 20:07:56 +0000 (20:07 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 May 2019 20:07:56 +0000 (20:07 +0000)
Breaks internal builds.

Reverted changeset:

"WeakPtr breaks vtables when upcasting to base classes"
https://bugs.webkit.org/show_bug.cgi?id=188799
https://trac.webkit.org/changeset/245857

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

53 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/WeakHashSet.h
Source/WTF/wtf/WeakPtr.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
Source/WebCore/css/CSSFontFace.cpp
Source/WebCore/css/CSSFontFace.h
Source/WebCore/css/parser/CSSDeferredParser.cpp
Source/WebCore/css/parser/CSSDeferredParser.h
Source/WebCore/dom/ContainerNode.h
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.h
Source/WebCore/dom/FullscreenManager.cpp
Source/WebCore/dom/FullscreenManager.h
Source/WebCore/html/FormAssociatedElement.cpp
Source/WebCore/html/FormAssociatedElement.h
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/loader/MediaResourceLoader.cpp
Source/WebCore/page/DOMWindowProperty.cpp
Source/WebCore/page/DOMWindowProperty.h
Source/WebCore/page/FrameViewLayoutContext.cpp
Source/WebCore/page/FrameViewLayoutContext.h
Source/WebCore/page/UndoItem.cpp
Source/WebCore/page/UndoItem.h
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/Widget.cpp
Source/WebCore/platform/Widget.h
Source/WebCore/platform/encryptedmedia/CDMInstanceSession.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBlockFlow.h
Source/WebCore/rendering/RenderMultiColumnFlow.cpp
Source/WebCore/rendering/RenderMultiColumnFlow.h
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTable.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
Source/WebKit/Shared/WebBackForwardListItem.cpp
Source/WebKit/Shared/WebBackForwardListItem.h
Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp
Source/WebKit/UIProcess/Authentication/cocoa/SecKeyProxyStore.h
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp

index 93dea43..810e18d 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245857.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "WeakPtr breaks vtables when upcasting to base classes"
+        https://bugs.webkit.org/show_bug.cgi?id=188799
+        https://trac.webkit.org/changeset/245857
+
 2019-05-28  Geoffrey Garen  <ggaren@apple.com>
 
         WeakPtr breaks vtables when upcasting to base classes
index 0bba1e0..092011c 100644 (file)
 
 namespace WTF {
 
-template<> struct HashTraits<Ref<WeakReference>> : RefHashTraits<WeakReference> {
-    static const bool hasIsReleasedWeakValueFunction = true;
-    static bool isReleasedWeakValue(const Ref<WeakReference>& value)
-    {
-        return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get();
-    }
-};
-
 template <typename T>
 class WeakHashSet {
 public:
-    typedef HashSet<Ref<WeakReference>> WeakReferenceSet;
+    typedef HashSet<Ref<WeakReference<T>>> WeakReferenceSet;
 
     class WeakHashSetConstIterator : public std::iterator<std::forward_iterator_tag, T, std::ptrdiff_t, const T*, const T&> {
     private:
@@ -54,7 +46,7 @@ public:
         }
 
     public:
-        T* get() const { return m_position->get().template get<T, typename T::WeakValueType>(); }
+        T* get() const { return m_position->get().get(); }
         T& operator*() const { return *get(); }
         T* operator->() const { return get(); }
 
@@ -68,7 +60,7 @@ public:
 
         void skipEmptyBuckets()
         {
-            while (m_position != m_endPosition && !get())
+            while (m_position != m_endPosition && !m_position->get().get())
                 ++m_position;
         }
 
@@ -104,33 +96,42 @@ public:
     template <typename U>
     bool remove(const U& value)
     {
-        auto& weakReference = value.weakPtrFactory().m_ref;
-        if (!weakReference || !*weakReference)
+        auto* weakReference = weak_reference_downcast<T>(value.weakPtrFactory().m_ref.get());
+        if (!weakReference)
             return false;
-        return m_set.remove(*weakReference);
+        return m_set.remove(weakReference);
     }
 
     template <typename U>
     bool contains(const U& value) const
     {
-        auto& weakReference = value.weakPtrFactory().m_ref;
-        if (!weakReference || !*weakReference)
+        auto* weakReference = weak_reference_downcast<T>(value.weakPtrFactory().m_ref.get());
+        if (!weakReference)
             return false;
-        return m_set.contains(*weakReference);
+        return m_set.contains(weakReference);
     }
 
     unsigned capacity() const { return m_set.capacity(); }
 
-    bool computesEmpty() const { return begin() == end(); }
+    bool computesEmpty() const
+    {
+        if (m_set.isEmpty())
+            return true;
+        for (auto& value : m_set) {
+            if (value->get())
+                return false;
+        }
+        return true;
+    }
 
     bool hasNullReferences() const
     {
-        return WTF::anyOf(m_set, [] (auto& value) { return !value.get(); });
+        return WTF::anyOf(m_set, [] (auto& value) { return !value->get(); });
     }
 
     unsigned computeSize() const
     {
-        const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value.get(); });
+        const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value->get(); });
         return m_set.size();
     }
 
@@ -144,6 +145,14 @@ private:
     WeakReferenceSet m_set;
 };
 
+template<typename T> struct HashTraits<Ref<WeakReference<T>>> : RefHashTraits<WeakReference<T>> {
+    static const bool hasIsReleasedWeakValueFunction = true;
+    static bool isReleasedWeakValue(const Ref<WeakReference<T>>& value)
+    {
+        return !value.isHashTableDeletedValue() && !value.isHashTableEmptyValue() && !value.get().get();
+    }
+};
+
 } // namespace WTF
 
 using WTF::WeakHashSet;
index fc3ac9c..2715d1f 100644 (file)
 
 namespace WTF {
 
-// Testing interface for TestWebKitAPI
-#ifndef DID_CREATE_WEAK_REFERENCE
-#define DID_CREATE_WEAK_REFERENCE(p)
-#endif
-#ifndef WILL_DESTROY_WEAK_REFERENCE
-#define WILL_DESTROY_WEAK_REFERENCE(p)
-#endif
-
 template<typename> class WeakHashSet;
 template<typename> class WeakPtr;
 template<typename> class WeakPtrFactory;
 
 // Note: WeakReference is an implementation detail, and should not be used directly.
-class WeakReference : public ThreadSafeRefCounted<WeakReference> {
-    WTF_MAKE_NONCOPYABLE(WeakReference);
+template<typename T>
+class WeakReference : public ThreadSafeRefCounted<WeakReference<T>> {
+    WTF_MAKE_NONCOPYABLE(WeakReference<T>);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    template<typename T> static Ref<WeakReference> create(T* ptr) { return adoptRef(*new WeakReference(ptr)); }
-
-    ~WeakReference()
-    {
-        WILL_DESTROY_WEAK_REFERENCE(m_ptr);
-    }
+    ~WeakReference() { } // So that we can use a template specialization for testing purposes to detect leaks.
 
-    template<typename T, typename WeakValueType> T* get() const { return static_cast<T*>(static_cast<WeakValueType*>(m_ptr)); }
-    explicit operator bool() const { return m_ptr; }
+    T* get() const { return m_ptr; }
 
     void clear() { m_ptr = nullptr; }
 
 private:
-    template<typename T> explicit WeakReference(T* ptr)
+    friend class WeakPtr<T>;
+    friend class WeakPtrFactory<T>;
+
+    static Ref<WeakReference<T>> create(T* ptr) { return adoptRef(*new WeakReference(ptr)); }
+
+    explicit WeakReference(T* ptr)
         : m_ptr(ptr)
     {
-        DID_CREATE_WEAK_REFERENCE(ptr);
     }
 
-    void* m_ptr;
+    T* m_ptr;
 };
 
 template<typename T>
@@ -78,29 +69,28 @@ class WeakPtr {
 public:
     WeakPtr() { }
     WeakPtr(std::nullptr_t) { }
+    WeakPtr(Ref<WeakReference<T>>&& ref) : m_ref(std::forward<Ref<WeakReference<T>>>(ref)) { }
     template<typename U> WeakPtr(const WeakPtr<U>&);
     template<typename U> WeakPtr(WeakPtr<U>&&);
 
-    T* get() const { return m_ref ? m_ref->template get<T, typename T::WeakValueType>() : nullptr; }
-    explicit operator bool() const { return m_ref && *m_ref; }
+    T* get() const { return m_ref ? m_ref->get() : nullptr; }
+    explicit operator bool() const { return m_ref && m_ref->get(); }
 
     WeakPtr& operator=(std::nullptr_t) { m_ref = nullptr; return *this; }
     template<typename U> WeakPtr& operator=(const WeakPtr<U>&);
     template<typename U> WeakPtr& operator=(WeakPtr<U>&&);
 
-    T* operator->() const { return get(); }
-    T& operator*() const { return *get(); }
+    T* operator->() const { return m_ref->get(); }
+    T& operator*() const { return *m_ref->get(); }
 
     void clear() { m_ref = nullptr; }
 
 private:
-    explicit WeakPtr(Ref<WeakReference>&& ref) : m_ref(std::move(ref)) { }
     template<typename> friend class WeakHashSet;
     template<typename> friend class WeakPtr;
-    template<typename> friend class WeakPtrFactory;
     template<typename U> friend WeakPtr<U> makeWeakPtr(U&);
 
-    RefPtr<WeakReference> m_ref;
+    RefPtr<WeakReference<T>> m_ref;
 };
 
 // Note: you probably want to inherit from CanMakeWeakPtr rather than use this directly.
@@ -120,15 +110,15 @@ public:
     WeakPtr<T> createWeakPtr(T& ptr) const
     {
         if (!m_ref)
-            m_ref = WeakReference::create(&ptr);
-        return WeakPtr<T>(makeRef(*m_ref));
+            m_ref = WeakReference<T>::create(&ptr);
+        return { makeRef(*m_ref) };
     }
 
     WeakPtr<const T> createWeakPtr(const T& ptr) const
     {
         if (!m_ref)
-            m_ref = WeakReference::create(const_cast<T*>(&ptr));
-        return WeakPtr<T>(makeRef(*m_ref));
+            m_ref = WeakReference<T>::create(const_cast<T*>(&ptr));
+        return { makeRef(reinterpret_cast<WeakReference<const T>&>(*m_ref)) };
     }
 
     void revokeAll()
@@ -143,13 +133,11 @@ public:
 private:
     template<typename> friend class WeakHashSet;
 
-    mutable RefPtr<WeakReference> m_ref;
+    mutable RefPtr<WeakReference<T>> m_ref;
 };
 
 template<typename T> class CanMakeWeakPtr {
 public:
-    typedef T WeakValueType;
-
     const WeakPtrFactory<T>& weakPtrFactory() const { return m_weakFactory; }
     WeakPtrFactory<T>& weakPtrFactory() { return m_weakFactory; }
 
@@ -157,37 +145,43 @@ private:
     WeakPtrFactory<T> m_weakFactory;
 };
 
-template<typename T, typename U> inline WeakReference* weak_reference_cast(WeakReference* weakReference)
+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*");
+    return reinterpret_cast<WeakReference<T>*>(weakReference);
+}
+
+template<typename T, typename U> inline WeakReference<T>* weak_reference_downcast(WeakReference<U>* weakReference)
 {
-    UNUSED_VARIABLE(static_cast<T*>(static_cast<typename U::WeakValueType*>(nullptr))); // Verify that casting is valid.
-    return weakReference;
+    static_assert(std::is_convertible<T*, U*>::value, "T* must be convertible to U*");
+    return reinterpret_cast<WeakReference<T>*>(weakReference);
 }
 
 template<typename T> template<typename U> inline WeakPtr<T>::WeakPtr(const WeakPtr<U>& o)
-    : m_ref(weak_reference_cast<T, U>(o.m_ref.get()))
+    : m_ref(weak_reference_upcast<T>(o.m_ref.get()))
 {
 }
 
 template<typename T> template<typename U> inline WeakPtr<T>::WeakPtr(WeakPtr<U>&& o)
-    : m_ref(adoptRef(weak_reference_cast<T, U>(o.m_ref.leakRef())))
+    : m_ref(adoptRef(weak_reference_upcast<T>(o.m_ref.leakRef())))
 {
 }
 
 template<typename T> template<typename U> inline WeakPtr<T>& WeakPtr<T>::operator=(const WeakPtr<U>& o)
 {
-    m_ref = weak_reference_cast<T, U>(o.m_ref.get());
+    m_ref = weak_reference_upcast<T>(o.m_ref.get());
     return *this;
 }
 
 template<typename T> template<typename U> inline WeakPtr<T>& WeakPtr<T>::operator=(WeakPtr<U>&& o)
 {
-    m_ref = adoptRef(weak_reference_cast<T, U>(o.m_ref.leakRef()));
+    m_ref = adoptRef(weak_reference_upcast<T>(o.m_ref.leakRef()));
     return *this;
 }
 
 template<typename T> inline WeakPtr<T> makeWeakPtr(T& ref)
 {
-    return { ref.weakPtrFactory().createWeakPtr(ref) };
+    return { adoptRef(*weak_reference_downcast<T>(ref.weakPtrFactory().createWeakPtr(ref).m_ref.leakRef())) };
 }
 
 template<typename T> inline WeakPtr<T> makeWeakPtr(T* ptr)
index 6257472..b9cacee 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245857.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "WeakPtr breaks vtables when upcasting to base classes"
+        https://bugs.webkit.org/show_bug.cgi?id=188799
+        https://trac.webkit.org/changeset/245857
+
 2019-05-29  Keith Rollin  <krollin@apple.com>
 
         Fix builds that don't use makeWindowFromView
index 612a2bd..c58adf6 100644 (file)
@@ -94,7 +94,7 @@ MediaKeySession::MediaKeySession(ScriptExecutionContext& context, WeakPtr<MediaK
     UNUSED_PARAM(m_closed);
     UNUSED_PARAM(m_uninitialized);
 
-    m_instanceSession->setClient(makeWeakPtr(*this));
+    m_instanceSession->setClient(m_cdmInstanceSessionClientWeakPtrFactory.createWeakPtr(*this));
 }
 
 MediaKeySession::~MediaKeySession()
index ded2dde..c9f60f1 100644 (file)
@@ -52,7 +52,7 @@ class MediaKeyStatusMap;
 class MediaKeys;
 class SharedBuffer;
 
-class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CDMInstanceSessionClient {
+class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CanMakeWeakPtr<MediaKeySession>, public CDMInstanceSessionClient {
     WTF_MAKE_ISO_ALLOCATED(MediaKeySession);
 public:
     static Ref<MediaKeySession> create(ScriptExecutionContext&, WeakPtr<MediaKeys>&&, MediaKeySessionType, bool useDistinctiveIdentifier, Ref<CDM>&&, Ref<CDMInstanceSession>&&);
@@ -120,6 +120,7 @@ private:
     double m_firstDecryptTime { 0 };
     double m_latestDecryptTime { 0 };
     Vector<std::pair<Ref<SharedBuffer>, MediaKeyStatus>> m_statuses;
+    WeakPtrFactory<CDMInstanceSessionClient> m_cdmInstanceSessionClientWeakPtrFactory;
 };
 
 } // namespace WebCore
index 7377adb..0f3e03f 100644 (file)
@@ -122,11 +122,6 @@ bool CSSFontFace::setFamilies(CSSValue& family)
     return true;
 }
 
-FontFace* CSSFontFace::existingWrapper()
-{
-    return m_wrapper.get();
-}
-
 static FontSelectionRange calculateWeightRange(CSSValue& value)
 {
     if (value.isValueList()) {
index a39a926..ad06d19 100644 (file)
@@ -150,7 +150,7 @@ public:
     // We don't guarantee that the FontFace wrapper will be the same every time you ask for it.
     Ref<FontFace> wrapper();
     void setWrapper(FontFace&);
-    FontFace* existingWrapper();
+    FontFace* existingWrapper() { return m_wrapper.get(); }
 
     struct FontLoadTiming {
         Seconds blockPeriod;
index 0f98a98..d34c19b 100644 (file)
@@ -39,11 +39,6 @@ CSSDeferredParser::CSSDeferredParser(const CSSParserContext& context, const Stri
 {
 }
 
-StyleSheetContents* CSSDeferredParser::styleSheet() const
-{
-    return m_styleSheet.get();
-}
-
 Ref<ImmutableStyleProperties> CSSDeferredParser::parseDeclaration(const CSSParserTokenRange& range)
 {
     return CSSParserImpl::parseDeferredDeclaration(range, m_context, m_styleSheet.get());
index bf84f27..07e9c92 100644 (file)
@@ -47,7 +47,7 @@ public:
     CSSParserMode mode() const { return m_context.mode; }
 
     const CSSParserContext& context() const { return m_context; }
-    StyleSheetContents* styleSheet() const;
+    StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
 
     Ref<ImmutableStyleProperties> parseDeclaration(const CSSParserTokenRange&);
     void parseRuleList(const CSSParserTokenRange&, Vector<RefPtr<StyleRuleBase>>&);
index 3f0571e..4a9bfdb 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "CollectionType.h"
 #include "Node.h"
-#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -36,7 +35,7 @@ class RenderElement;
 const int initialNodeVectorSize = 11; // Covers 99.5%. See webkit.org/b/80706
 typedef Vector<Ref<Node>, initialNodeVectorSize> NodeVector;
 
-class ContainerNode : public CanMakeWeakPtr<ContainerNode>, public Node {
+class ContainerNode : public Node {
     WTF_MAKE_ISO_ALLOCATED(ContainerNode);
 public:
     virtual ~ContainerNode();
index 69ef47b..16d0410 100644 (file)
@@ -347,6 +347,7 @@ class Document
     , public TreeScope
     , public ScriptExecutionContext
     , public FontSelectorClient
+    , public CanMakeWeakPtr<Document>
     , public FrameDestructionObserver
     , public Supplementable<Document>
     , public Logger::Observer {
index 8ded545..c6016e0 100644 (file)
@@ -77,7 +77,7 @@ enum SpellcheckAttributeState {
 enum class TouchAction : uint8_t;
 #endif
 
-class Element : public ContainerNode {
+class Element : public ContainerNode , public CanMakeWeakPtr<Element> {
     WTF_MAKE_ISO_ALLOCATED(Element);
 public:
     static Ref<Element> create(const QualifiedName&, Document&);
index 6f92c90..b55ed2b 100644 (file)
@@ -439,11 +439,6 @@ void FullscreenManager::setFullscreenRenderer(RenderTreeBuilder& builder, Render
     m_fullscreenRenderer = makeWeakPtr(renderer);
 }
 
-RenderFullScreen* FullscreenManager::fullscreenRenderer() const
-{
-    return m_fullscreenRenderer.get();
-}
-
 void FullscreenManager::dispatchFullscreenChangeEvents()
 {
     // Since we dispatch events in this function, it's possible that the
index ebdaa95..7ab5a7b 100644 (file)
@@ -79,7 +79,7 @@ public:
     WEBCORE_EXPORT void didExitFullscreen();
 
     void setFullscreenRenderer(RenderTreeBuilder&, RenderFullScreen&);
-    RenderFullScreen* fullscreenRenderer() const;
+    RenderFullScreen* fullscreenRenderer() const { return m_fullscreenRenderer.get(); }
 
     void dispatchFullscreenChangeEvents();
     bool fullscreenIsAllowedForElement(Element&) const;
index bd42622..25220cb 100644 (file)
@@ -119,11 +119,6 @@ HTMLFormElement* FormAssociatedElement::findAssociatedForm(const HTMLElement* el
     return currentAssociatedForm;
 }
 
-HTMLFormElement* FormAssociatedElement::form() const
-{
-    return m_form.get();
-}
-
 void FormAssociatedElement::formOwnerRemovedFromTree(const Node& formRoot)
 {
     ASSERT(m_form);
index 88639de..5c84a19 100644 (file)
@@ -48,7 +48,7 @@ public:
     void deref() { derefFormAssociatedElement(); }
 
     static HTMLFormElement* findAssociatedForm(const HTMLElement*, HTMLFormElement*);
-    WEBCORE_EXPORT HTMLFormElement* form() const;
+    HTMLFormElement* form() const { return m_form.get(); }
     ValidityState* validity();
 
     virtual bool isFormControlElement() const = 0;
index ed88e3c..2fff363 100644 (file)
@@ -149,9 +149,6 @@ class HTMLMediaElement
 {
     WTF_MAKE_ISO_ALLOCATED(HTMLMediaElement);
 public:
-    typedef HTMLElement::WeakValueType WeakValueType;
-    using HTMLElement::weakPtrFactory;
-
     RefPtr<MediaPlayer> player() const { return m_player; }
 
     virtual bool isVideo() const { return false; }
@@ -578,6 +575,8 @@ public:
 
     enum class AutoplayEventPlaybackState { None, PreventedAutoplay, StartedWithUserGesture, StartedWithoutUserGesture };
 
+    using HTMLElement::weakPtrFactory;
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
     virtual void finishInitialization();
index 06e847d..db29143 100644 (file)
@@ -97,7 +97,7 @@ RefPtr<PlatformMediaResource> MediaResourceLoader::requestResource(ResourceReque
     loaderOptions.destination = m_mediaElement && !m_mediaElement->isVideo() ? FetchOptions::Destination::Audio : FetchOptions::Destination::Video;
     auto cachedRequest = createPotentialAccessControlRequest(WTFMove(request), *m_document, m_crossOriginMode, WTFMove(loaderOptions));
     if (m_mediaElement)
-        cachedRequest.setInitiator(*m_mediaElement);
+        cachedRequest.setInitiator(*m_mediaElement.get());
 
     auto resource = m_document->cachedResourceLoader().requestMedia(WTFMove(cachedRequest)).value_or(nullptr);
     if (!resource)
index 7bb61c2..b87f2e5 100644 (file)
@@ -42,9 +42,4 @@ Frame* DOMWindowProperty::frame() const
     return m_window ? m_window->frame() : nullptr;
 }
 
-DOMWindow* DOMWindowProperty::window() const
-{
-    return m_window.get();
-}
-
 }
index 0aaafb3..fb77175 100644 (file)
@@ -35,7 +35,7 @@ class Frame;
 class DOMWindowProperty {
 public:
     Frame* frame() const;
-    DOMWindow* window() const;
+    DOMWindow* window() const { return m_window.get(); }
 
 protected:
     explicit DOMWindowProperty(DOMWindow*);
index 327b6ea..fd1fa60 100644 (file)
@@ -458,11 +458,6 @@ void FrameViewLayoutContext::layoutTimerFired()
     layout();
 }
 
-RenderElement* FrameViewLayoutContext::subtreeLayoutRoot() const
-{
-    return m_subtreeLayoutRoot.get();
-}
-
 void FrameViewLayoutContext::convertSubtreeLayoutToFullLayout()
 {
     ASSERT(subtreeLayoutRoot());
index b2ca37b..d16f6c3 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "LayoutUnit.h"
 #include "Timer.h"
+
 #include <wtf/WeakPtr.h>
 
 namespace WebCore {
@@ -81,7 +82,7 @@ public:
 
     unsigned layoutCount() const { return m_layoutCount; }
 
-    RenderElement* subtreeLayoutRoot() const;
+    RenderElement* subtreeLayoutRoot() const { return m_subtreeLayoutRoot.get(); }
     void clearSubtreeLayoutRoot() { m_subtreeLayoutRoot.clear(); }
     void convertSubtreeLayoutToFullLayout();
 
index e03f1f0..2b32137 100644 (file)
@@ -33,11 +33,6 @@ namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(UndoItem);
 
-UndoManager* UndoItem::undoManager() const
-{
-    return m_undoManager.get();
-}
-
 void UndoItem::setUndoManager(UndoManager* undoManager)
 {
     m_undoManager = makeWeakPtr(undoManager);
index 386d476..6f0b5a1 100644 (file)
@@ -55,7 +55,7 @@ public:
 
     Document* document() const;
 
-    UndoManager* undoManager() const;
+    UndoManager* undoManager() const { return m_undoManager.get(); }
     void setUndoManager(UndoManager*);
 
     const String& label() const { return m_label; }
index d847a20..7d824c4 100644 (file)
@@ -65,9 +65,6 @@ class ScrollView : public Widget, public ScrollableArea {
 public:
     virtual ~ScrollView();
 
-    typedef Widget::WeakValueType WeakValueType;
-    using Widget::weakPtrFactory;
-
     // ScrollableArea functions.
     int scrollSize(ScrollbarOrientation) const final;
     int scrollOffset(ScrollbarOrientation) const final;
@@ -77,6 +74,8 @@ public:
 
     virtual void notifyPageThatContentAreaWillPaint() const;
 
+    using Widget::weakPtrFactory;
+
     IntPoint locationOfContents() const;
 
     // NOTE: This should only be called by the overridden setScrollOffset from ScrollableArea.
index 6cc645e..48570aa 100644 (file)
@@ -42,11 +42,6 @@ void Widget::init(PlatformWidget widget)
         retainPlatformWidget();
 }
 
-ScrollView* Widget::parent() const
-{
-    return m_parent.get();
-}
-
 void Widget::setParent(ScrollView* view)
 {
     ASSERT(!view || !m_parent);
index f2879cc..2aeaeab 100644 (file)
@@ -140,7 +140,7 @@ public:
 
     WEBCORE_EXPORT void removeFromParent();
     WEBCORE_EXPORT virtual void setParent(ScrollView* view);
-    WEBCORE_EXPORT ScrollView* parent() const;
+    ScrollView* parent() const { return m_parent.get(); }
     FrameView* root() const;
 
     virtual void handleEvent(Event&) { }
index a71ab8e..8d12a01 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
 class SharedBuffer;
 
-class CDMInstanceSessionClient : public CanMakeWeakPtr<CDMInstanceSessionClient> {
+class CDMInstanceSessionClient {
 public:
     virtual ~CDMInstanceSessionClient() = default;
 
index 2a709ff..7587ad5 100644 (file)
@@ -337,6 +337,7 @@ private:
     bool performTaskAtMediaTime(WTF::Function<void()>&&, MediaTime) final;
     void setShouldObserveTimeControlStatus(bool);
 
+    WeakPtrFactory<MediaPlayerPrivateAVFoundationObjC> m_weakPtrFactory;
     RetainPtr<AVURLAsset> m_avAsset;
     RetainPtr<AVPlayer> m_avPlayer;
     RetainPtr<AVPlayerItem> m_avPlayerItem;
index 94365fe..c123ed5 100644 (file)
@@ -359,14 +359,14 @@ MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlay
     : MediaPlayerPrivateAVFoundation(player)
     , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManagerObjC>())
     , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
-    , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:makeWeakPtr(*this)]))
+    , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:m_weakPtrFactory.createWeakPtr(*this)]))
     , m_videoFrameHasDrawn(false)
     , m_haveCheckedPlayability(false)
 #if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
-    , m_videoOutputDelegate(adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:makeWeakPtr(*this)]))
+    , m_videoOutputDelegate(adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:m_weakPtrFactory.createWeakPtr(*this)]))
 #endif
 #if HAVE(AVFOUNDATION_LOADER_DELEGATE)
-    , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithPlayer:makeWeakPtr(*this)]))
+    , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithPlayer:m_weakPtrFactory.createWeakPtr(*this)]))
 #endif
     , m_currentTextTrack(0)
     , m_cachedRate(0)
@@ -387,7 +387,7 @@ MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlay
 
 MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC()
 {
-    weakPtrFactory().revokeAll();
+    m_weakPtrFactory.revokeAll();
 
 #if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     [[m_avAsset.get() resourceLoader] setDelegate:nil queue:0];
index bf38721..5180c9f 100644 (file)
@@ -59,8 +59,7 @@ class WebCoreDecompressionSession;
 
 
 class MediaPlayerPrivateMediaSourceAVFObjC
-    : public CanMakeWeakPtr<MediaPlayerPrivateMediaSourceAVFObjC>
-    , public MediaPlayerPrivateInterface
+    : public MediaPlayerPrivateInterface
 #if !RELEASE_LOG_DISABLED
     , private LoggerHelper
 #endif
@@ -122,7 +121,7 @@ public:
     AVStreamSession *streamSession();
 #endif
     void setCDMSession(LegacyCDMSession*) override;
-    CDMSessionMediaSourceAVFObjC* cdmSession() const;
+    CDMSessionMediaSourceAVFObjC* cdmSession() const { return m_session.get(); }
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA)
@@ -148,6 +147,8 @@ public:
     const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
     bool shouldCheckHardwareSupport() const;
 
+    WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
+
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return m_logger.get(); }
     const char* logClassName() const override { return "MediaPlayerPrivateMediaSourceAVFObjC"; }
@@ -281,6 +282,7 @@ private:
     std::unique_ptr<PendingSeek> m_pendingSeek;
 
     MediaPlayer* m_player;
+    WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_weakPtrFactory;
     WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_sizeChangeObserverWeakPtrFactory;
     RefPtr<MediaSourcePrivateAVFObjC> m_mediaSourcePrivate;
     RetainPtr<AVAsset> m_asset;
index 78e6247..2513b4b 100644 (file)
@@ -52,7 +52,6 @@
 #import <wtf/FileSystem.h>
 #import <wtf/MainThread.h>
 #import <wtf/NeverDestroyed.h>
-#import <wtf/WeakPtr.h>
 
 #import "CoreVideoSoftLink.h"
 #import <pal/cf/CoreMediaSoftLink.h>
@@ -88,10 +87,10 @@ String convertEnumerationToString(MediaPlayerPrivateMediaSourceAVFObjC::SeekStat
 static void CMTimebaseEffectiveRateChangedCallback(CMNotificationCenterRef, const void *listener, CFStringRef, const void *, CFTypeRef)
 {
     MediaPlayerPrivateMediaSourceAVFObjC* player = (MediaPlayerPrivateMediaSourceAVFObjC*)const_cast<void*>(listener);
-    callOnMainThread([weakThis = makeWeakPtr(player)] {
+    callOnMainThread([weakThis = player->createWeakPtr()] {
         if (!weakThis)
             return;
-        weakThis->effectiveRateChanged();
+        weakThis.get()->effectiveRateChanged();
     });
 }
 
@@ -121,7 +120,7 @@ MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(Media
 
     // addPeriodicTimeObserverForInterval: throws an exception if you pass a non-numeric CMTime, so just use
     // an arbitrarily large time value of once an hour:
-    __block auto weakThis = makeWeakPtr(*this);
+    __block auto weakThis = createWeakPtr();
     m_timeJumpedObserver = [m_synchronizer addPeriodicTimeObserverForInterval:PAL::toCMTime(MediaTime::createWithDouble(3600)) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
 #if LOG_DISABLED
         UNUSED_PARAM(time);
@@ -287,7 +286,7 @@ PlatformLayer* MediaPlayerPrivateMediaSourceAVFObjC::platformLayer() const
 void MediaPlayerPrivateMediaSourceAVFObjC::play()
 {
     ALWAYS_LOG(LOGIDENTIFIER);
-    callOnMainThread([weakThis = makeWeakPtr(*this)] {
+    callOnMainThread([weakThis = createWeakPtr()] {
         if (!weakThis)
             return;
         weakThis.get()->playInternal();
@@ -308,7 +307,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::playInternal()
 void MediaPlayerPrivateMediaSourceAVFObjC::pause()
 {
     ALWAYS_LOG(LOGIDENTIFIER);
-    callOnMainThread([weakThis = makeWeakPtr(*this)] {
+    callOnMainThread([weakThis = createWeakPtr()] {
         if (!weakThis)
             return;
         weakThis.get()->pauseInternal();
@@ -408,6 +407,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance(const MediaTime& ti
     INFO_LOG(LOGIDENTIFIER, "time = ", time, ", negativeThreshold = ", negativeThreshold, ", positiveThreshold = ", positiveThreshold);
 
     m_seeking = true;
+    auto weakThis = createWeakPtr();
     m_pendingSeek = std::make_unique<PendingSeek>(time, negativeThreshold, positiveThreshold);
 
     if (m_seekTimer.isActive())
@@ -858,13 +858,14 @@ void MediaPlayerPrivateMediaSourceAVFObjC::durationChanged()
         return;
 
     MediaTime duration = m_mediaSourcePrivate->duration();
+    auto weakThis = createWeakPtr();
     NSArray* times = @[[NSValue valueWithCMTime:PAL::toCMTime(duration)]];
 
     auto logSiteIdentifier = LOGIDENTIFIER;
     DEBUG_LOG(logSiteIdentifier, duration);
     UNUSED_PARAM(logSiteIdentifier);
 
-    m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis = makeWeakPtr(*this), duration, logSiteIdentifier, this] {
+    m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis, duration, logSiteIdentifier, this] {
         if (!weakThis)
             return;
 
@@ -954,11 +955,6 @@ AVStreamSession* MediaPlayerPrivateMediaSourceAVFObjC::streamSession()
 }
 #endif
 
-CDMSessionMediaSourceAVFObjC* MediaPlayerPrivateMediaSourceAVFObjC::cdmSession() const
-{
-    return m_session.get();
-}
-
 void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(LegacyCDMSession* session)
 {
     if (session == m_session)
index 705082e..a73f920 100644 (file)
@@ -175,10 +175,13 @@ private:
     void flush(AVSampleBufferAudioRenderer *);
     ALLOW_NEW_API_WITHOUT_GUARDS_END
 
+    WeakPtr<SourceBufferPrivateAVFObjC> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
+
     Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks;
     Vector<RefPtr<AudioTrackPrivateMediaSourceAVFObjC>> m_audioTracks;
     Vector<SourceBufferPrivateAVFObjCErrorClient*> m_errorClients;
 
+    WeakPtrFactory<SourceBufferPrivateAVFObjC> m_weakFactory;
     WeakPtrFactory<SourceBufferPrivateAVFObjC> m_appendWeakFactory;
 
     RetainPtr<AVStreamDataParser> m_parser;
index 4b877b9..00be37a 100644 (file)
@@ -465,8 +465,8 @@ Ref<SourceBufferPrivateAVFObjC> SourceBufferPrivateAVFObjC::create(MediaSourcePr
 
 SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
     : m_parser(adoptNS([PAL::allocAVStreamDataParserInstance() init]))
-    , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:makeWeakPtr(*this)]))
-    , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:makeWeakPtr(*this)]))
+    , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]))
+    , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:createWeakPtr()]))
     , m_isAppendingGroup(adoptOSObject(dispatch_group_create()))
     , m_mediaSource(parent)
     , m_mapID(nextMapID())
@@ -884,7 +884,7 @@ void SourceBufferPrivateAVFObjC::trackDidChangeEnabled(AudioTrackPrivateMediaSou
         ALLOW_NEW_API_WITHOUT_GUARDS_END
         if (!m_audioRenderers.contains(trackID)) {
             renderer = adoptNS([PAL::allocAVSampleBufferAudioRendererInstance() init]);
-            auto weakThis = makeWeakPtr(*this);
+            auto weakThis = createWeakPtr();
             [renderer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
                 if (weakThis)
                     weakThis->didBecomeReadyForMoreSamples(trackID);
@@ -920,7 +920,8 @@ void SourceBufferPrivateAVFObjC::setCDMSession(CDMSessionMediaSourceAVFObjC* ses
         }
 
         if (m_hdcpError) {
-            callOnMainThread([weakThis = makeWeakPtr(*this)] {
+            WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr();
+            callOnMainThread([weakThis] {
                 if (!weakThis || !weakThis->m_session || !weakThis->m_hdcpError)
                     return;
 
@@ -1064,7 +1065,7 @@ void SourceBufferPrivateAVFObjC::flushVideo()
 
     if (m_decompressionSession) {
         m_decompressionSession->flush();
-        m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = makeWeakPtr(*this)] {
+        m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = createWeakPtr()] {
             if (weakThis && weakThis->m_mediaSource)
                 weakThis->m_mediaSource->player()->setHasAvailableVideoFrame(true);
         });
@@ -1137,7 +1138,7 @@ void SourceBufferPrivateAVFObjC::enqueueSample(Ref<MediaSample>&& sample, const
 #endif
             } else {
                 [m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer];
-                [m_displayLayer prerollDecodeWithCompletionHandler:[weakThis = makeWeakPtr(*this)] (BOOL success) mutable {
+                [m_displayLayer prerollDecodeWithCompletionHandler:[weakThis = createWeakPtr()] (BOOL success) mutable {
                     if (!success || !weakThis)
                         return;
 
@@ -1236,14 +1237,14 @@ void SourceBufferPrivateAVFObjC::notifyClientWhenReadyForMoreSamples(const Atomi
             });
         }
         if (m_displayLayer) {
-            auto weakThis = makeWeakPtr(*this);
+            auto weakThis = createWeakPtr();
             [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ {
                 if (weakThis)
                     weakThis->didBecomeReadyForMoreSamples(trackID);
             }];
         }
     } else if (m_audioRenderers.contains(trackID)) {
-        auto weakThis = makeWeakPtr(*this);
+        auto weakThis = createWeakPtr();
         [m_audioRenderers.get(trackID) requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ {
             if (weakThis)
                 weakThis->didBecomeReadyForMoreSamples(trackID);
@@ -1277,7 +1278,7 @@ void SourceBufferPrivateAVFObjC::setVideoLayer(AVSampleBufferDisplayLayer* layer
     m_displayLayer = layer;
 
     if (m_displayLayer) {
-        auto weakThis = makeWeakPtr(*this);
+        auto weakThis = createWeakPtr();
         [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ {
             if (weakThis)
                 weakThis->didBecomeReadyForMoreSamples(m_enabledVideoTrackID);
@@ -1305,11 +1306,12 @@ void SourceBufferPrivateAVFObjC::setDecompressionSession(WebCoreDecompressionSes
     if (!m_decompressionSession)
         return;
 
-    m_decompressionSession->requestMediaDataWhenReady([weakThis = makeWeakPtr(*this)] {
+    WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr();
+    m_decompressionSession->requestMediaDataWhenReady([weakThis] {
         if (weakThis)
             weakThis->didBecomeReadyForMoreSamples(weakThis->m_enabledVideoTrackID);
     });
-    m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = makeWeakPtr(*this)] {
+    m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = createWeakPtr()] {
         if (weakThis && weakThis->m_mediaSource)
             weakThis->m_mediaSource->player()->setHasAvailableVideoFrame(true);
     });
index ddb821b..042c2cc 100644 (file)
@@ -159,11 +159,6 @@ void RenderBlockFlow::willBeDestroyed()
     RenderBox::willBeDestroyed();
 }
 
-RenderMultiColumnFlow* RenderBlockFlow::multiColumnFlowSlowCase() const
-{
-    return rareBlockFlowData()->m_multiColumnFlow.get();
-}
-
 RenderBlockFlow* RenderBlockFlow::previousSiblingWithOverhangingFloats(bool& parentHasFloats) const
 {
     // Attempt to locate a previous sibling with overhanging floats. We skip any elements that are
index 42db8e9..bdbbe3c 100644 (file)
@@ -264,8 +264,7 @@ public:
     }
     void layoutLineGridBox();
 
-    RenderMultiColumnFlow* multiColumnFlow() const { return hasRareBlockFlowData() ? multiColumnFlowSlowCase() : nullptr; }
-    RenderMultiColumnFlow* multiColumnFlowSlowCase() const;
+    RenderMultiColumnFlow* multiColumnFlow() const { return hasRareBlockFlowData() ? rareBlockFlowData()->m_multiColumnFlow.get() : nullptr; }
     void setMultiColumnFlow(RenderMultiColumnFlow&);
     void clearMultiColumnFlow();
     bool willCreateColumns(Optional<unsigned> desiredColumnCount = WTF::nullopt) const;
index 9bb9a53..c866c34 100644 (file)
@@ -107,11 +107,6 @@ RenderBox* RenderMultiColumnFlow::previousColumnSetOrSpannerSiblingOf(const Rend
     return nullptr;
 }
 
-RenderMultiColumnSpannerPlaceholder* RenderMultiColumnFlow::findColumnSpannerPlaceholder(RenderBox* spanner) const
-{
-    return m_spannerMap->get(spanner).get();
-}
-
 void RenderMultiColumnFlow::layout()
 {
     ASSERT(!m_inLayout);
index bca4d94..a48a789 100644 (file)
@@ -48,7 +48,7 @@ public:
     static RenderBox* nextColumnSetOrSpannerSiblingOf(const RenderBox*);
     static RenderBox* previousColumnSetOrSpannerSiblingOf(const RenderBox*);
 
-    RenderMultiColumnSpannerPlaceholder* findColumnSpannerPlaceholder(RenderBox* spanner) const;
+    RenderMultiColumnSpannerPlaceholder* findColumnSpannerPlaceholder(RenderBox* spanner) const { return m_spannerMap->get(spanner).get(); }
 
     void layout() override;
 
index 186ca87..221851f 100644 (file)
@@ -96,31 +96,6 @@ RenderTable::RenderTable(Document& document, RenderStyle&& style)
 
 RenderTable::~RenderTable() = default;
 
-RenderTableSection* RenderTable::header() const
-{
-    return m_head.get();
-}
-
-RenderTableSection* RenderTable::footer() const
-{
-    return m_foot.get();
-}
-
-RenderTableSection* RenderTable::firstBody() const
-{
-    return m_firstBody.get();
-}
-
-RenderTableSection* RenderTable::topSection() const
-{
-    ASSERT(!needsSectionRecalc());
-    if (m_head)
-        return m_head.get();
-    if (m_firstBody)
-        return m_firstBody.get();
-    return m_foot.get();
-}
-
 void RenderTable::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
     RenderBlock::styleDidChange(diff, oldStyle);
index a71e269..346cf5d 100644 (file)
@@ -152,9 +152,9 @@ public:
         m_columnPos[index] = position;
     }
 
-    RenderTableSection* header() const;
-    RenderTableSection* footer() const;
-    RenderTableSection* firstBody() const;
+    RenderTableSection* header() const { return m_head.get(); }
+    RenderTableSection* footer() const { return m_foot.get(); }
+    RenderTableSection* firstBody() const { return m_firstBody.get(); }
 
     // This function returns 0 if the table has no section.
     RenderTableSection* topSection() const;
@@ -370,6 +370,16 @@ private:
     bool m_inRecursiveSectionMovedWithPagination { false };
 };
 
+inline RenderTableSection* RenderTable::topSection() const
+{
+    ASSERT(!needsSectionRecalc());
+    if (m_head)
+        return m_head.get();
+    if (m_firstBody)
+        return m_firstBody.get();
+    return m_foot.get();
+}
+
 inline bool isDirectionSame(const RenderBox* tableItem, const RenderBox* otherTableItem) { return tableItem && otherTableItem ? tableItem->style().direction() == otherTableItem->style().direction() : true; }
 
 inline RenderPtr<RenderBox> RenderTable::createAnonymousBoxWithSameTypeAs(const RenderBox& renderer) const
index f40e8eb..a5d1997 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245857.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "WeakPtr breaks vtables when upcasting to base classes"
+        https://bugs.webkit.org/show_bug.cgi?id=188799
+        https://trac.webkit.org/changeset/245857
+
 2019-05-29  Chris Dumez  <cdumez@apple.com>
 
         [iOS] The WebContent process needs proper entitlement to do secure drawing
index 914d35b..622430c 100644 (file)
@@ -1016,11 +1016,6 @@ void WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed()
         m_networkSession->notifyResourceLoadStatisticsProcessed();
 }
 
-NetworkSession* WebResourceLoadStatisticsStore::networkSession()
-{
-    return m_networkSession.get();
-}
-
 void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domainsToRemoveWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
index a8c23e0..79cf246 100644 (file)
@@ -175,7 +175,7 @@ public:
 
     void notifyResourceLoadStatisticsProcessed();
 
-    NetworkSession* networkSession();
+    NetworkSession* networkSession() { return m_networkSession.get(); }
 
     void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const;
     void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const;
index db72ca1..d900a16 100644 (file)
@@ -168,11 +168,6 @@ void WebBackForwardListItem::setSuspendedPage(SuspendedPageProxy* page)
     m_suspendedPage = makeWeakPtr(page);
 }
 
-SuspendedPageProxy* WebBackForwardListItem::suspendedPage() const
-{
-    return m_suspendedPage.get();
-}
-
 void WebBackForwardListItem::removeSuspendedPageFromProcessPool()
 {
     if (!m_suspendedPage)
index 5b2d2e0..44af7c6 100644 (file)
@@ -75,7 +75,7 @@ public:
     void setSnapshot(RefPtr<ViewSnapshot>&& snapshot) { m_itemState.snapshot = WTFMove(snapshot); }
 #endif
     void setSuspendedPage(SuspendedPageProxy*);
-    SuspendedPageProxy* suspendedPage() const;
+    SuspendedPageProxy* suspendedPage() const { return m_suspendedPage.get(); }
 
 #if !LOG_DISABLED
     const char* loggingString();
index 288555f..c29212e 100644 (file)
@@ -24,7 +24,6 @@
 #include "WebFrameProxy.h"
 #include "WebKitURIRequest.h"
 #include "WebKitWebResourcePrivate.h"
-#include "WebPageProxy.h"
 #include <glib/gi18n-lib.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/glib/WTFGType.h>
index 60e4a1b..bec75cf 100644 (file)
@@ -39,7 +39,7 @@ class Credential;
 
 namespace WebKit {
 
-class SecKeyProxyStore : public RefCounted<SecKeyProxyStore>, public CanMakeWeakPtr<SecKeyProxyStore> {
+class SecKeyProxyStore : public RefCounted<SecKeyProxyStore> {
 public:
     static Ref<SecKeyProxyStore> create() { return adoptRef(* new SecKeyProxyStore()); }
 
@@ -47,10 +47,12 @@ public:
     bool isInitialized() const { return !!m_secKeyProxy; }
 
     auto* get() const { return m_secKeyProxy.get(); }
+    auto& weakPtrFactory() const { return m_weakPtrFactory; }
 
 private:
     SecKeyProxyStore() = default;
 
+    WeakPtrFactory<SecKeyProxyStore> m_weakPtrFactory;
     RetainPtr<SecKeyProxy> m_secKeyProxy;
 };
 
index ce06c50..b03fe57 100644 (file)
@@ -49,7 +49,6 @@ public:
     using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>;
 
     using AuthenticatorTransportService::Observer::weakPtrFactory;
-    typedef AuthenticatorTransportService::Observer::WeakValueType WeakValueType;
 
     AuthenticatorManager();
     virtual ~AuthenticatorManager() = default;
index 5603c8a..67831e2 100644 (file)
@@ -1513,12 +1513,6 @@ void WebProcessProxy::decrementSuspendedPageCount()
         send(Messages::WebProcess::SetHasSuspendedPageProxy(false), 0);
 }
 
-WebProcessPool& WebProcessProxy::processPool() const
-{
-    ASSERT(m_processPool);
-    return *m_processPool.get();
-}
-
 #if PLATFORM(WATCHOS)
 
 void WebProcessProxy::takeBackgroundActivityTokenForFullscreenInput()
index 063e861..ad3f038 100644 (file)
@@ -119,7 +119,7 @@ public:
     void incrementSuspendedPageCount();
     void decrementSuspendedPageCount();
 
-    WebProcessPool& processPool() const;
+    WebProcessPool& processPool() const { ASSERT(m_processPool); return *m_processPool.get(); }
 
     WebCore::RegistrableDomain registrableDomain() const { return m_registrableDomain.valueOr(WebCore::RegistrableDomain { }); }
     void setIsInProcessCache(bool);
index f4efe07..a2ccc8f 100644 (file)
@@ -1,3 +1,15 @@
+2019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r245857.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "WeakPtr breaks vtables when upcasting to base classes"
+        https://bugs.webkit.org/show_bug.cgi?id=188799
+        https://trac.webkit.org/changeset/245857
+
 2019-05-28  Geoffrey Garen  <ggaren@apple.com>
 
         WeakPtr breaks vtables when upcasting to base classes
index 62ce632..e0e7c31 100644 (file)
 
 #include "config.h"
 
-static unsigned s_baseWeakReferences = 0;
-
-#define DID_CREATE_WEAK_REFERENCE(p) do { \
-    ++s_baseWeakReferences; \
-} while (0);
-
-#define WILL_DESTROY_WEAK_REFERENCE(p) do { \
-    --s_baseWeakReferences; \
-} while (0);
-
 #include "Test.h"
 #include <wtf/HashSet.h>
 #include <wtf/WeakHashSet.h>
 #include <wtf/WeakPtr.h>
 
-namespace TestWebKitAPI {
+static unsigned s_baseWeakReferences = 0;
 
-struct Int : public CanMakeWeakPtr<Int> {
-    Int(int i) : m_i(i) { }
-    operator int() const { return m_i; }
-    bool operator==(const Int& other) const { return m_i == other.m_i; }
-    int m_i;
-};
+namespace TestWebKitAPI {
 
-class Base : public CanMakeWeakPtr<Base> {
+class Base {
 public:
     Base() { }
 
@@ -58,15 +43,16 @@ public:
         return 0;
     }
 
-    int dummy; // Prevent empty base class optimization, to make testing more interesting.
+    auto& weakPtrFactory() const { return m_weakPtrFactory; }
+
+private:
+    WeakPtrFactory<Base> m_weakPtrFactory;
 };
 
 class Derived : public Base {
 public:
     Derived() { }
 
-    virtual ~Derived() { } // Force a pointer fixup when casting Base <-> Derived
-
     int foo()
     {
         return 1;
@@ -75,15 +61,31 @@ public:
 
 }
 
+namespace WTF {
+
+template<>
+WeakReference<TestWebKitAPI::Base>::WeakReference(TestWebKitAPI::Base* ptr)
+    : m_ptr(ptr)
+{
+    ++s_baseWeakReferences;
+}
+template<>
+WeakReference<TestWebKitAPI::Base>::~WeakReference()
+{
+    --s_baseWeakReferences;
+}
+
+}
+
 namespace TestWebKitAPI {
 
 TEST(WTF_WeakPtr, Basic)
 {
-    Int dummy(5);
-    WeakPtrFactory<Int>* factory = new WeakPtrFactory<Int>();
-    WeakPtr<Int> weakPtr1 = factory->createWeakPtr(dummy);
-    WeakPtr<Int> weakPtr2 = factory->createWeakPtr(dummy);
-    WeakPtr<Int> weakPtr3 = factory->createWeakPtr(dummy);
+    int dummy = 5;
+    WeakPtrFactory<int>* factory = new WeakPtrFactory<int>();
+    WeakPtr<int> weakPtr1 = factory->createWeakPtr(dummy);
+    WeakPtr<int> weakPtr2 = factory->createWeakPtr(dummy);
+    WeakPtr<int> weakPtr3 = factory->createWeakPtr(dummy);
     EXPECT_EQ(weakPtr1.get(), &dummy);
     EXPECT_EQ(weakPtr2.get(), &dummy);
     EXPECT_EQ(weakPtr3.get(), &dummy);
@@ -104,10 +106,10 @@ TEST(WTF_WeakPtr, Basic)
 
 TEST(WTF_WeakPtr, Assignment)
 {
-    Int dummy(5);
-    WeakPtr<Int> weakPtr;
+    int dummy = 5;
+    WeakPtr<int> weakPtr;
     {
-        WeakPtrFactory<Int> factory;
+        WeakPtrFactory<int> factory;
         EXPECT_NULL(weakPtr.get());
         weakPtr = factory.createWeakPtr(dummy);
         EXPECT_EQ(weakPtr.get(), &dummy);
@@ -117,12 +119,12 @@ TEST(WTF_WeakPtr, Assignment)
 
 TEST(WTF_WeakPtr, MultipleFactories)
 {
-    Int dummy1(5);
-    Int dummy2(7);
-    WeakPtrFactory<Int>* factory1 = new WeakPtrFactory<Int>();
-    WeakPtrFactory<Int>* factory2 = new WeakPtrFactory<Int>();
-    WeakPtr<Int> weakPtr1 = factory1->createWeakPtr(dummy1);
-    WeakPtr<Int> weakPtr2 = factory2->createWeakPtr(dummy2);
+    int dummy1 = 5;
+    int dummy2 = 7;
+    WeakPtrFactory<int>* factory1 = new WeakPtrFactory<int>();
+    WeakPtrFactory<int>* factory2 = new WeakPtrFactory<int>();
+    WeakPtr<int> weakPtr1 = factory1->createWeakPtr(dummy1);
+    WeakPtr<int> weakPtr2 = factory2->createWeakPtr(dummy2);
     EXPECT_EQ(weakPtr1.get(), &dummy1);
     EXPECT_EQ(weakPtr2.get(), &dummy2);
     EXPECT_TRUE(weakPtr1 != weakPtr2);
@@ -137,11 +139,11 @@ TEST(WTF_WeakPtr, MultipleFactories)
 
 TEST(WTF_WeakPtr, RevokeAll)
 {
-    Int dummy(5);
-    WeakPtrFactory<Int> factory;
-    WeakPtr<Int> weakPtr1 = factory.createWeakPtr(dummy);
-    WeakPtr<Int> weakPtr2 = factory.createWeakPtr(dummy);
-    WeakPtr<Int> weakPtr3 = factory.createWeakPtr(dummy);
+    int dummy = 5;
+    WeakPtrFactory<int> factory;
+    WeakPtr<int> weakPtr1 = factory.createWeakPtr(dummy);
+    WeakPtr<int> weakPtr2 = factory.createWeakPtr(dummy);
+    WeakPtr<int> weakPtr3 = factory.createWeakPtr(dummy);
     EXPECT_EQ(weakPtr1.get(), &dummy);
     EXPECT_EQ(weakPtr2.get(), &dummy);
     EXPECT_EQ(weakPtr3.get(), &dummy);
@@ -151,7 +153,7 @@ TEST(WTF_WeakPtr, RevokeAll)
     EXPECT_NULL(weakPtr3.get());
 }
 
-struct Foo : public CanMakeWeakPtr<Foo> {
+struct Foo {
     void bar() { };
 };
 
@@ -183,13 +185,13 @@ TEST(WTF_WeakPtr, Operators)
 
 TEST(WTF_WeakPtr, Forget)
 {
-    Int dummy(5);
-    Int dummy2(7);
+    int dummy = 5;
+    int dummy2 = 7;
 
-    WeakPtrFactory<Int> outerFactory;
-    WeakPtr<Int> weakPtr1, weakPtr2, weakPtr3, weakPtr4;
+    WeakPtrFactory<int> outerFactory;
+    WeakPtr<int> weakPtr1, weakPtr2, weakPtr3, weakPtr4;
     {
-        WeakPtrFactory<Int> innerFactory;
+        WeakPtrFactory<int> innerFactory;
         weakPtr1 = innerFactory.createWeakPtr(dummy);
         weakPtr2 = innerFactory.createWeakPtr(dummy);
         weakPtr3 = innerFactory.createWeakPtr(dummy);
@@ -215,7 +217,7 @@ TEST(WTF_WeakPtr, Forget)
         EXPECT_EQ(weakPtr2.get(), &dummy);
         EXPECT_EQ(weakPtr4.get(), &dummy);
 
-        WeakPtr<Int> weakPtr5 = weakPtr2;
+        WeakPtr<int> weakPtr5 = weakPtr2;
         EXPECT_EQ(weakPtr2.get(), &dummy);
         EXPECT_EQ(weakPtr5.get(), &dummy);
         weakPtr5.clear();
@@ -231,16 +233,16 @@ TEST(WTF_WeakPtr, Forget)
     EXPECT_NULL(weakPtr2.get());
     EXPECT_EQ(weakPtr4.get(), &dummy2);
 
-    WeakPtr<Int> weakPtr5 = weakPtr4;
+    WeakPtr<int> weakPtr5 = weakPtr4;
     EXPECT_EQ(weakPtr4.get(), &dummy2);
     EXPECT_EQ(weakPtr5.get(), &dummy2);
     weakPtr5.clear();
     EXPECT_NULL(weakPtr5.get());
-    WeakPtr<Int> weakPtr6 = weakPtr5;
+    WeakPtr<int> weakPtr6 = weakPtr5;
     EXPECT_NULL(weakPtr6.get());
     EXPECT_EQ(weakPtr5.get(), weakPtr6.get());
 
-    WeakPtr<Int> weakPtr7 = outerFactory.createWeakPtr(dummy2);
+    WeakPtr<int> weakPtr7 = outerFactory.createWeakPtr(dummy2);
     EXPECT_EQ(weakPtr7.get(), &dummy2);
     weakPtr7 = nullptr;
     EXPECT_NULL(weakPtr7.get());
@@ -248,8 +250,8 @@ TEST(WTF_WeakPtr, Forget)
 
 TEST(WTF_WeakPtr, Downcasting)
 {
-    int dummy0(0);
-    int dummy1(1);
+    int dummy0 = 0;
+    int dummy1 = 1;
 
     WeakPtr<Base> baseWeakPtr;
     WeakPtr<Derived> derivedWeakPtr;