Changeset 245863 in webkit


Ignore:
Timestamp:
May 29, 2019 1:07:56 PM (5 years ago)
Author:
Ryan Haddad
Message:

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

Location:
trunk
Files:
53 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r245857 r245863  
     12019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r245857.
     4
     5        Breaks internal builds.
     6
     7        Reverted changeset:
     8
     9        "WeakPtr breaks vtables when upcasting to base classes"
     10        https://bugs.webkit.org/show_bug.cgi?id=188799
     11        https://trac.webkit.org/changeset/245857
     12
    1132019-05-28  Geoffrey Garen  <ggaren@apple.com>
    214
  • trunk/Source/WTF/wtf/WeakHashSet.h

    r245857 r245863  
    3333namespace WTF {
    3434
    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 
    4335template <typename T>
    4436class WeakHashSet {
    4537public:
    46     typedef HashSet<Ref<WeakReference>> WeakReferenceSet;
     38    typedef HashSet<Ref<WeakReference<T>>> WeakReferenceSet;
    4739
    4840    class WeakHashSetConstIterator : public std::iterator<std::forward_iterator_tag, T, std::ptrdiff_t, const T*, const T&> {
     
    5547
    5648    public:
    57         T* get() const { return m_position->get().template get<T, typename T::WeakValueType>(); }
     49        T* get() const { return m_position->get().get(); }
    5850        T& operator*() const { return *get(); }
    5951        T* operator->() const { return get(); }
     
    6961        void skipEmptyBuckets()
    7062        {
    71             while (m_position != m_endPosition && !get())
     63            while (m_position != m_endPosition && !m_position->get().get())
    7264                ++m_position;
    7365        }
     
    10597    bool remove(const U& value)
    10698    {
    107         auto& weakReference = value.weakPtrFactory().m_ref;
    108         if (!weakReference || !*weakReference)
     99        auto* weakReference = weak_reference_downcast<T>(value.weakPtrFactory().m_ref.get());
     100        if (!weakReference)
    109101            return false;
    110         return m_set.remove(*weakReference);
     102        return m_set.remove(weakReference);
    111103    }
    112104
     
    114106    bool contains(const U& value) const
    115107    {
    116         auto& weakReference = value.weakPtrFactory().m_ref;
    117         if (!weakReference || !*weakReference)
     108        auto* weakReference = weak_reference_downcast<T>(value.weakPtrFactory().m_ref.get());
     109        if (!weakReference)
    118110            return false;
    119         return m_set.contains(*weakReference);
     111        return m_set.contains(weakReference);
    120112    }
    121113
    122114    unsigned capacity() const { return m_set.capacity(); }
    123115
    124     bool computesEmpty() const { return begin() == end(); }
     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    }
    125126
    126127    bool hasNullReferences() const
    127128    {
    128         return WTF::anyOf(m_set, [] (auto& value) { return !value.get(); });
     129        return WTF::anyOf(m_set, [] (auto& value) { return !value->get(); });
    129130    }
    130131
    131132    unsigned computeSize() const
    132133    {
    133         const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value.get(); });
     134        const_cast<WeakReferenceSet&>(m_set).removeIf([] (auto& value) { return !value->get(); });
    134135        return m_set.size();
    135136    }
     
    145146};
    146147
     148template<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
    147156} // namespace WTF
    148157
  • trunk/Source/WTF/wtf/WeakPtr.h

    r245857 r245863  
    3434namespace WTF {
    3535
    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 
    4436template<typename> class WeakHashSet;
    4537template<typename> class WeakPtr;
     
    4739
    4840// Note: WeakReference is an implementation detail, and should not be used directly.
    49 class WeakReference : public ThreadSafeRefCounted<WeakReference> {
    50     WTF_MAKE_NONCOPYABLE(WeakReference);
     41template<typename T>
     42class WeakReference : public ThreadSafeRefCounted<WeakReference<T>> {
     43    WTF_MAKE_NONCOPYABLE(WeakReference<T>);
    5144    WTF_MAKE_FAST_ALLOCATED;
    5245public:
    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; }
     46    ~WeakReference() { } // So that we can use a template specialization for testing purposes to detect leaks.
     47
     48    T* get() const { return m_ptr; }
    6249
    6350    void clear() { m_ptr = nullptr; }
    6451
    6552private:
    66     template<typename T> explicit WeakReference(T* ptr)
     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)
    6759        : m_ptr(ptr)
    6860    {
    69         DID_CREATE_WEAK_REFERENCE(ptr);
    70     }
    71 
    72     void* m_ptr;
     61    }
     62
     63    T* m_ptr;
    7364};
    7465
     
    7970    WeakPtr() { }
    8071    WeakPtr(std::nullptr_t) { }
     72    WeakPtr(Ref<WeakReference<T>>&& ref) : m_ref(std::forward<Ref<WeakReference<T>>>(ref)) { }
    8173    template<typename U> WeakPtr(const WeakPtr<U>&);
    8274    template<typename U> WeakPtr(WeakPtr<U>&&);
    8375
    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; }
     76    T* get() const { return m_ref ? m_ref->get() : nullptr; }
     77    explicit operator bool() const { return m_ref && m_ref->get(); }
    8678
    8779    WeakPtr& operator=(std::nullptr_t) { m_ref = nullptr; return *this; }
     
    8981    template<typename U> WeakPtr& operator=(WeakPtr<U>&&);
    9082
    91     T* operator->() const { return get(); }
    92     T& operator*() const { return *get(); }
     83    T* operator->() const { return m_ref->get(); }
     84    T& operator*() const { return *m_ref->get(); }
    9385
    9486    void clear() { m_ref = nullptr; }
    9587
    9688private:
    97     explicit WeakPtr(Ref<WeakReference>&& ref) : m_ref(std::move(ref)) { }
    9889    template<typename> friend class WeakHashSet;
    9990    template<typename> friend class WeakPtr;
    100     template<typename> friend class WeakPtrFactory;
    10191    template<typename U> friend WeakPtr<U> makeWeakPtr(U&);
    10292
    103     RefPtr<WeakReference> m_ref;
     93    RefPtr<WeakReference<T>> m_ref;
    10494};
    10595
     
    121111    {
    122112        if (!m_ref)
    123             m_ref = WeakReference::create(&ptr);
    124         return WeakPtr<T>(makeRef(*m_ref));
     113            m_ref = WeakReference<T>::create(&ptr);
     114        return { makeRef(*m_ref) };
    125115    }
    126116
     
    128118    {
    129119        if (!m_ref)
    130             m_ref = WeakReference::create(const_cast<T*>(&ptr));
    131         return WeakPtr<T>(makeRef(*m_ref));
     120            m_ref = WeakReference<T>::create(const_cast<T*>(&ptr));
     121        return { makeRef(reinterpret_cast<WeakReference<const T>&>(*m_ref)) };
    132122    }
    133123
     
    144134    template<typename> friend class WeakHashSet;
    145135
    146     mutable RefPtr<WeakReference> m_ref;
     136    mutable RefPtr<WeakReference<T>> m_ref;
    147137};
    148138
    149139template<typename T> class CanMakeWeakPtr {
    150140public:
    151     typedef T WeakValueType;
    152 
    153141    const WeakPtrFactory<T>& weakPtrFactory() const { return m_weakFactory; }
    154142    WeakPtrFactory<T>& weakPtrFactory() { return m_weakFactory; }
     
    158146};
    159147
    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;
     148template<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
     154template<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);
    164158}
    165159
    166160template<typename T> template<typename U> inline WeakPtr<T>::WeakPtr(const WeakPtr<U>& o)
    167     : m_ref(weak_reference_cast<T, U>(o.m_ref.get()))
     161    : m_ref(weak_reference_upcast<T>(o.m_ref.get()))
    168162{
    169163}
    170164
    171165template<typename T> template<typename U> inline WeakPtr<T>::WeakPtr(WeakPtr<U>&& o)
    172     : m_ref(adoptRef(weak_reference_cast<T, U>(o.m_ref.leakRef())))
     166    : m_ref(adoptRef(weak_reference_upcast<T>(o.m_ref.leakRef())))
    173167{
    174168}
     
    176170template<typename T> template<typename U> inline WeakPtr<T>& WeakPtr<T>::operator=(const WeakPtr<U>& o)
    177171{
    178     m_ref = weak_reference_cast<T, U>(o.m_ref.get());
     172    m_ref = weak_reference_upcast<T>(o.m_ref.get());
    179173    return *this;
    180174}
     
    182176template<typename T> template<typename U> inline WeakPtr<T>& WeakPtr<T>::operator=(WeakPtr<U>&& o)
    183177{
    184     m_ref = adoptRef(weak_reference_cast<T, U>(o.m_ref.leakRef()));
     178    m_ref = adoptRef(weak_reference_upcast<T>(o.m_ref.leakRef()));
    185179    return *this;
    186180}
     
    188182template<typename T> inline WeakPtr<T> makeWeakPtr(T& ref)
    189183{
    190     return { ref.weakPtrFactory().createWeakPtr(ref) };
     184    return { adoptRef(*weak_reference_downcast<T>(ref.weakPtrFactory().createWeakPtr(ref).m_ref.leakRef())) };
    191185}
    192186
  • trunk/Source/WebCore/ChangeLog

    r245861 r245863  
     12019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r245857.
     4
     5        Breaks internal builds.
     6
     7        Reverted changeset:
     8
     9        "WeakPtr breaks vtables when upcasting to base classes"
     10        https://bugs.webkit.org/show_bug.cgi?id=188799
     11        https://trac.webkit.org/changeset/245857
     12
    1132019-05-29  Keith Rollin  <krollin@apple.com>
    214
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp

    r245857 r245863  
    9595    UNUSED_PARAM(m_uninitialized);
    9696
    97     m_instanceSession->setClient(makeWeakPtr(*this));
     97    m_instanceSession->setClient(m_cdmInstanceSessionClientWeakPtrFactory.createWeakPtr(*this));
    9898}
    9999
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h

    r245857 r245863  
    5353class SharedBuffer;
    5454
    55 class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CDMInstanceSessionClient {
     55class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CanMakeWeakPtr<MediaKeySession>, public CDMInstanceSessionClient {
    5656    WTF_MAKE_ISO_ALLOCATED(MediaKeySession);
    5757public:
     
    121121    double m_latestDecryptTime { 0 };
    122122    Vector<std::pair<Ref<SharedBuffer>, MediaKeyStatus>> m_statuses;
     123    WeakPtrFactory<CDMInstanceSessionClient> m_cdmInstanceSessionClientWeakPtrFactory;
    123124};
    124125
  • trunk/Source/WebCore/css/CSSFontFace.cpp

    r245857 r245863  
    123123}
    124124
    125 FontFace* CSSFontFace::existingWrapper()
    126 {
    127     return m_wrapper.get();
    128 }
    129 
    130125static FontSelectionRange calculateWeightRange(CSSValue& value)
    131126{
  • trunk/Source/WebCore/css/CSSFontFace.h

    r245857 r245863  
    151151    Ref<FontFace> wrapper();
    152152    void setWrapper(FontFace&);
    153     FontFace* existingWrapper();
     153    FontFace* existingWrapper() { return m_wrapper.get(); }
    154154
    155155    struct FontLoadTiming {
  • trunk/Source/WebCore/css/parser/CSSDeferredParser.cpp

    r245857 r245863  
    4040}
    4141
    42 StyleSheetContents* CSSDeferredParser::styleSheet() const
    43 {
    44     return m_styleSheet.get();
    45 }
    46 
    4742Ref<ImmutableStyleProperties> CSSDeferredParser::parseDeclaration(const CSSParserTokenRange& range)
    4843{
  • trunk/Source/WebCore/css/parser/CSSDeferredParser.h

    r245857 r245863  
    4848
    4949    const CSSParserContext& context() const { return m_context; }
    50     StyleSheetContents* styleSheet() const;
     50    StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
    5151
    5252    Ref<ImmutableStyleProperties> parseDeclaration(const CSSParserTokenRange&);
  • trunk/Source/WebCore/dom/ContainerNode.h

    r245857 r245863  
    2626#include "CollectionType.h"
    2727#include "Node.h"
    28 #include <wtf/WeakPtr.h>
    2928
    3029namespace WebCore {
     
    3736typedef Vector<Ref<Node>, initialNodeVectorSize> NodeVector;
    3837
    39 class ContainerNode : public CanMakeWeakPtr<ContainerNode>, public Node {
     38class ContainerNode : public Node {
    4039    WTF_MAKE_ISO_ALLOCATED(ContainerNode);
    4140public:
  • trunk/Source/WebCore/dom/Document.h

    r245857 r245863  
    348348    , public ScriptExecutionContext
    349349    , public FontSelectorClient
     350    , public CanMakeWeakPtr<Document>
    350351    , public FrameDestructionObserver
    351352    , public Supplementable<Document>
  • trunk/Source/WebCore/dom/Element.h

    r245857 r245863  
    7878#endif
    7979
    80 class Element : public ContainerNode {
     80class Element : public ContainerNode , public CanMakeWeakPtr<Element> {
    8181    WTF_MAKE_ISO_ALLOCATED(Element);
    8282public:
  • trunk/Source/WebCore/dom/FullscreenManager.cpp

    r245857 r245863  
    440440}
    441441
    442 RenderFullScreen* FullscreenManager::fullscreenRenderer() const
    443 {
    444     return m_fullscreenRenderer.get();
    445 }
    446 
    447442void FullscreenManager::dispatchFullscreenChangeEvents()
    448443{
  • trunk/Source/WebCore/dom/FullscreenManager.h

    r245857 r245863  
    8080
    8181    void setFullscreenRenderer(RenderTreeBuilder&, RenderFullScreen&);
    82     RenderFullScreen* fullscreenRenderer() const;
     82    RenderFullScreen* fullscreenRenderer() const { return m_fullscreenRenderer.get(); }
    8383
    8484    void dispatchFullscreenChangeEvents();
  • trunk/Source/WebCore/html/FormAssociatedElement.cpp

    r245857 r245863  
    120120}
    121121
    122 HTMLFormElement* FormAssociatedElement::form() const
    123 {
    124     return m_form.get();
    125 }
    126 
    127122void FormAssociatedElement::formOwnerRemovedFromTree(const Node& formRoot)
    128123{
  • trunk/Source/WebCore/html/FormAssociatedElement.h

    r245857 r245863  
    4949
    5050    static HTMLFormElement* findAssociatedForm(const HTMLElement*, HTMLFormElement*);
    51     WEBCORE_EXPORT HTMLFormElement* form() const;
     51    HTMLFormElement* form() const { return m_form.get(); }
    5252    ValidityState* validity();
    5353
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r245857 r245863  
    150150    WTF_MAKE_ISO_ALLOCATED(HTMLMediaElement);
    151151public:
    152     typedef HTMLElement::WeakValueType WeakValueType;
    153     using HTMLElement::weakPtrFactory;
    154 
    155152    RefPtr<MediaPlayer> player() const { return m_player; }
    156153
     
    578575
    579576    enum class AutoplayEventPlaybackState { None, PreventedAutoplay, StartedWithUserGesture, StartedWithoutUserGesture };
     577
     578    using HTMLElement::weakPtrFactory;
    580579
    581580protected:
  • trunk/Source/WebCore/loader/MediaResourceLoader.cpp

    r245857 r245863  
    9898    auto cachedRequest = createPotentialAccessControlRequest(WTFMove(request), *m_document, m_crossOriginMode, WTFMove(loaderOptions));
    9999    if (m_mediaElement)
    100         cachedRequest.setInitiator(*m_mediaElement);
     100        cachedRequest.setInitiator(*m_mediaElement.get());
    101101
    102102    auto resource = m_document->cachedResourceLoader().requestMedia(WTFMove(cachedRequest)).value_or(nullptr);
  • trunk/Source/WebCore/page/DOMWindowProperty.cpp

    r245857 r245863  
    4343}
    4444
    45 DOMWindow* DOMWindowProperty::window() const
    46 {
    47     return m_window.get();
    4845}
    49 
    50 }
  • trunk/Source/WebCore/page/DOMWindowProperty.h

    r245857 r245863  
    3636public:
    3737    Frame* frame() const;
    38     DOMWindow* window() const;
     38    DOMWindow* window() const { return m_window.get(); }
    3939
    4040protected:
  • trunk/Source/WebCore/page/FrameViewLayoutContext.cpp

    r245857 r245863  
    459459}
    460460
    461 RenderElement* FrameViewLayoutContext::subtreeLayoutRoot() const
    462 {
    463     return m_subtreeLayoutRoot.get();
    464 }
    465 
    466461void FrameViewLayoutContext::convertSubtreeLayoutToFullLayout()
    467462{
  • trunk/Source/WebCore/page/FrameViewLayoutContext.h

    r245857 r245863  
    2828#include "LayoutUnit.h"
    2929#include "Timer.h"
     30
    3031#include <wtf/WeakPtr.h>
    3132
     
    8283    unsigned layoutCount() const { return m_layoutCount; }
    8384
    84     RenderElement* subtreeLayoutRoot() const;
     85    RenderElement* subtreeLayoutRoot() const { return m_subtreeLayoutRoot.get(); }
    8586    void clearSubtreeLayoutRoot() { m_subtreeLayoutRoot.clear(); }
    8687    void convertSubtreeLayoutToFullLayout();
  • trunk/Source/WebCore/page/UndoItem.cpp

    r245857 r245863  
    3434WTF_MAKE_ISO_ALLOCATED_IMPL(UndoItem);
    3535
    36 UndoManager* UndoItem::undoManager() const
    37 {
    38     return m_undoManager.get();
    39 }
    40 
    4136void UndoItem::setUndoManager(UndoManager* undoManager)
    4237{
  • trunk/Source/WebCore/page/UndoItem.h

    r245857 r245863  
    5656    Document* document() const;
    5757
    58     UndoManager* undoManager() const;
     58    UndoManager* undoManager() const { return m_undoManager.get(); }
    5959    void setUndoManager(UndoManager*);
    6060
  • trunk/Source/WebCore/platform/ScrollView.h

    r245857 r245863  
    6666    virtual ~ScrollView();
    6767
    68     typedef Widget::WeakValueType WeakValueType;
    69     using Widget::weakPtrFactory;
    70 
    7168    // ScrollableArea functions.
    7269    int scrollSize(ScrollbarOrientation) const final;
     
    7774
    7875    virtual void notifyPageThatContentAreaWillPaint() const;
     76
     77    using Widget::weakPtrFactory;
    7978
    8079    IntPoint locationOfContents() const;
  • trunk/Source/WebCore/platform/Widget.cpp

    r245857 r245863  
    4343}
    4444
    45 ScrollView* Widget::parent() const
    46 {
    47     return m_parent.get();
    48 }
    49 
    5045void Widget::setParent(ScrollView* view)
    5146{
  • trunk/Source/WebCore/platform/Widget.h

    r245857 r245863  
    141141    WEBCORE_EXPORT void removeFromParent();
    142142    WEBCORE_EXPORT virtual void setParent(ScrollView* view);
    143     WEBCORE_EXPORT ScrollView* parent() const;
     143    ScrollView* parent() const { return m_parent.get(); }
    144144    FrameView* root() const;
    145145
  • trunk/Source/WebCore/platform/encryptedmedia/CDMInstanceSession.h

    r245857 r245863  
    4040class SharedBuffer;
    4141
    42 class CDMInstanceSessionClient : public CanMakeWeakPtr<CDMInstanceSessionClient> {
     42class CDMInstanceSessionClient {
    4343public:
    4444    virtual ~CDMInstanceSessionClient() = default;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r245857 r245863  
    338338    void setShouldObserveTimeControlStatus(bool);
    339339
     340    WeakPtrFactory<MediaPlayerPrivateAVFoundationObjC> m_weakPtrFactory;
    340341    RetainPtr<AVURLAsset> m_avAsset;
    341342    RetainPtr<AVPlayer> m_avPlayer;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r245857 r245863  
    360360    , m_videoFullscreenLayerManager(std::make_unique<VideoFullscreenLayerManagerObjC>())
    361361    , m_videoFullscreenGravity(MediaPlayer::VideoGravityResizeAspect)
    362     , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:makeWeakPtr(*this)]))
     362    , m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:m_weakPtrFactory.createWeakPtr(*this)]))
    363363    , m_videoFrameHasDrawn(false)
    364364    , m_haveCheckedPlayability(false)
    365365#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
    366     , m_videoOutputDelegate(adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:makeWeakPtr(*this)]))
     366    , m_videoOutputDelegate(adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:m_weakPtrFactory.createWeakPtr(*this)]))
    367367#endif
    368368#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
    369     , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithPlayer:makeWeakPtr(*this)]))
     369    , m_loaderDelegate(adoptNS([[WebCoreAVFLoaderDelegate alloc] initWithPlayer:m_weakPtrFactory.createWeakPtr(*this)]))
    370370#endif
    371371    , m_currentTextTrack(0)
     
    388388MediaPlayerPrivateAVFoundationObjC::~MediaPlayerPrivateAVFoundationObjC()
    389389{
    390     weakPtrFactory().revokeAll();
     390    m_weakPtrFactory.revokeAll();
    391391
    392392#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r245857 r245863  
    6060
    6161class MediaPlayerPrivateMediaSourceAVFObjC
    62     : public CanMakeWeakPtr<MediaPlayerPrivateMediaSourceAVFObjC>
    63     , public MediaPlayerPrivateInterface
     62    : public MediaPlayerPrivateInterface
    6463#if !RELEASE_LOG_DISABLED
    6564    , private LoggerHelper
     
    123122#endif
    124123    void setCDMSession(LegacyCDMSession*) override;
    125     CDMSessionMediaSourceAVFObjC* cdmSession() const;
     124    CDMSessionMediaSourceAVFObjC* cdmSession() const { return m_session.get(); }
    126125#endif
    127126
     
    148147    const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
    149148    bool shouldCheckHardwareSupport() const;
     149
     150    WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
    150151
    151152#if !RELEASE_LOG_DISABLED
     
    282283
    283284    MediaPlayer* m_player;
     285    WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_weakPtrFactory;
    284286    WeakPtrFactory<MediaPlayerPrivateMediaSourceAVFObjC> m_sizeChangeObserverWeakPtrFactory;
    285287    RefPtr<MediaSourcePrivateAVFObjC> m_mediaSourcePrivate;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r245857 r245863  
    5353#import <wtf/MainThread.h>
    5454#import <wtf/NeverDestroyed.h>
    55 #import <wtf/WeakPtr.h>
    5655
    5756#import "CoreVideoSoftLink.h"
     
    8988{
    9089    MediaPlayerPrivateMediaSourceAVFObjC* player = (MediaPlayerPrivateMediaSourceAVFObjC*)const_cast<void*>(listener);
    91     callOnMainThread([weakThis = makeWeakPtr(player)] {
     90    callOnMainThread([weakThis = player->createWeakPtr()] {
    9291        if (!weakThis)
    9392            return;
    94         weakThis->effectiveRateChanged();
     93        weakThis.get()->effectiveRateChanged();
    9594    });
    9695}
     
    122121    // addPeriodicTimeObserverForInterval: throws an exception if you pass a non-numeric CMTime, so just use
    123122    // an arbitrarily large time value of once an hour:
    124     __block auto weakThis = makeWeakPtr(*this);
     123    __block auto weakThis = createWeakPtr();
    125124    m_timeJumpedObserver = [m_synchronizer addPeriodicTimeObserverForInterval:PAL::toCMTime(MediaTime::createWithDouble(3600)) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
    126125#if LOG_DISABLED
     
    288287{
    289288    ALWAYS_LOG(LOGIDENTIFIER);
    290     callOnMainThread([weakThis = makeWeakPtr(*this)] {
     289    callOnMainThread([weakThis = createWeakPtr()] {
    291290        if (!weakThis)
    292291            return;
     
    309308{
    310309    ALWAYS_LOG(LOGIDENTIFIER);
    311     callOnMainThread([weakThis = makeWeakPtr(*this)] {
     310    callOnMainThread([weakThis = createWeakPtr()] {
    312311        if (!weakThis)
    313312            return;
     
    409408
    410409    m_seeking = true;
     410    auto weakThis = createWeakPtr();
    411411    m_pendingSeek = std::make_unique<PendingSeek>(time, negativeThreshold, positiveThreshold);
    412412
     
    859859
    860860    MediaTime duration = m_mediaSourcePrivate->duration();
     861    auto weakThis = createWeakPtr();
    861862    NSArray* times = @[[NSValue valueWithCMTime:PAL::toCMTime(duration)]];
    862863
     
    865866    UNUSED_PARAM(logSiteIdentifier);
    866867
    867     m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis = makeWeakPtr(*this), duration, logSiteIdentifier, this] {
     868    m_durationObserver = [m_synchronizer addBoundaryTimeObserverForTimes:times queue:dispatch_get_main_queue() usingBlock:[weakThis, duration, logSiteIdentifier, this] {
    868869        if (!weakThis)
    869870            return;
     
    955956#endif
    956957
    957 CDMSessionMediaSourceAVFObjC* MediaPlayerPrivateMediaSourceAVFObjC::cdmSession() const
    958 {
    959     return m_session.get();
    960 }
    961 
    962958void MediaPlayerPrivateMediaSourceAVFObjC::setCDMSession(LegacyCDMSession* session)
    963959{
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h

    r245857 r245863  
    176176    ALLOW_NEW_API_WITHOUT_GUARDS_END
    177177
     178    WeakPtr<SourceBufferPrivateAVFObjC> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
     179
    178180    Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks;
    179181    Vector<RefPtr<AudioTrackPrivateMediaSourceAVFObjC>> m_audioTracks;
    180182    Vector<SourceBufferPrivateAVFObjCErrorClient*> m_errorClients;
    181183
     184    WeakPtrFactory<SourceBufferPrivateAVFObjC> m_weakFactory;
    182185    WeakPtrFactory<SourceBufferPrivateAVFObjC> m_appendWeakFactory;
    183186
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm

    r245857 r245863  
    466466SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
    467467    : m_parser(adoptNS([PAL::allocAVStreamDataParserInstance() init]))
    468     , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:makeWeakPtr(*this)]))
    469     , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:makeWeakPtr(*this)]))
     468    , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]))
     469    , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:createWeakPtr()]))
    470470    , m_isAppendingGroup(adoptOSObject(dispatch_group_create()))
    471471    , m_mediaSource(parent)
     
    885885        if (!m_audioRenderers.contains(trackID)) {
    886886            renderer = adoptNS([PAL::allocAVSampleBufferAudioRendererInstance() init]);
    887             auto weakThis = makeWeakPtr(*this);
     887            auto weakThis = createWeakPtr();
    888888            [renderer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
    889889                if (weakThis)
     
    921921
    922922        if (m_hdcpError) {
    923             callOnMainThread([weakThis = makeWeakPtr(*this)] {
     923            WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr();
     924            callOnMainThread([weakThis] {
    924925                if (!weakThis || !weakThis->m_session || !weakThis->m_hdcpError)
    925926                    return;
     
    10651066    if (m_decompressionSession) {
    10661067        m_decompressionSession->flush();
    1067         m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = makeWeakPtr(*this)] {
     1068        m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = createWeakPtr()] {
    10681069            if (weakThis && weakThis->m_mediaSource)
    10691070                weakThis->m_mediaSource->player()->setHasAvailableVideoFrame(true);
     
    11381139            } else {
    11391140                [m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer];
    1140                 [m_displayLayer prerollDecodeWithCompletionHandler:[weakThis = makeWeakPtr(*this)] (BOOL success) mutable {
     1141                [m_displayLayer prerollDecodeWithCompletionHandler:[weakThis = createWeakPtr()] (BOOL success) mutable {
    11411142                    if (!success || !weakThis)
    11421143                        return;
     
    12371238        }
    12381239        if (m_displayLayer) {
    1239             auto weakThis = makeWeakPtr(*this);
     1240            auto weakThis = createWeakPtr();
    12401241            [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ {
    12411242                if (weakThis)
     
    12441245        }
    12451246    } else if (m_audioRenderers.contains(trackID)) {
    1246         auto weakThis = makeWeakPtr(*this);
     1247        auto weakThis = createWeakPtr();
    12471248        [m_audioRenderers.get(trackID) requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ {
    12481249            if (weakThis)
     
    12781279
    12791280    if (m_displayLayer) {
    1280         auto weakThis = makeWeakPtr(*this);
     1281        auto weakThis = createWeakPtr();
    12811282        [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^ {
    12821283            if (weakThis)
     
    13061307        return;
    13071308
    1308     m_decompressionSession->requestMediaDataWhenReady([weakThis = makeWeakPtr(*this)] {
     1309    WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr();
     1310    m_decompressionSession->requestMediaDataWhenReady([weakThis] {
    13091311        if (weakThis)
    13101312            weakThis->didBecomeReadyForMoreSamples(weakThis->m_enabledVideoTrackID);
    13111313    });
    1312     m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = makeWeakPtr(*this)] {
     1314    m_decompressionSession->notifyWhenHasAvailableVideoFrame([weakThis = createWeakPtr()] {
    13131315        if (weakThis && weakThis->m_mediaSource)
    13141316            weakThis->m_mediaSource->player()->setHasAvailableVideoFrame(true);
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r245857 r245863  
    160160}
    161161
    162 RenderMultiColumnFlow* RenderBlockFlow::multiColumnFlowSlowCase() const
    163 {
    164     return rareBlockFlowData()->m_multiColumnFlow.get();
    165 }
    166 
    167162RenderBlockFlow* RenderBlockFlow::previousSiblingWithOverhangingFloats(bool& parentHasFloats) const
    168163{
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r245857 r245863  
    265265    void layoutLineGridBox();
    266266
    267     RenderMultiColumnFlow* multiColumnFlow() const { return hasRareBlockFlowData() ? multiColumnFlowSlowCase() : nullptr; }
    268     RenderMultiColumnFlow* multiColumnFlowSlowCase() const;
     267    RenderMultiColumnFlow* multiColumnFlow() const { return hasRareBlockFlowData() ? rareBlockFlowData()->m_multiColumnFlow.get() : nullptr; }
    269268    void setMultiColumnFlow(RenderMultiColumnFlow&);
    270269    void clearMultiColumnFlow();
  • trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp

    r245857 r245863  
    108108}
    109109
    110 RenderMultiColumnSpannerPlaceholder* RenderMultiColumnFlow::findColumnSpannerPlaceholder(RenderBox* spanner) const
    111 {
    112     return m_spannerMap->get(spanner).get();
    113 }
    114 
    115110void RenderMultiColumnFlow::layout()
    116111{
  • trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h

    r245857 r245863  
    4949    static RenderBox* previousColumnSetOrSpannerSiblingOf(const RenderBox*);
    5050
    51     RenderMultiColumnSpannerPlaceholder* findColumnSpannerPlaceholder(RenderBox* spanner) const;
     51    RenderMultiColumnSpannerPlaceholder* findColumnSpannerPlaceholder(RenderBox* spanner) const { return m_spannerMap->get(spanner).get(); }
    5252
    5353    void layout() override;
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r245857 r245863  
    9696
    9797RenderTable::~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 }
    12398
    12499void RenderTable::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
  • trunk/Source/WebCore/rendering/RenderTable.h

    r245857 r245863  
    153153    }
    154154
    155     RenderTableSection* header() const;
    156     RenderTableSection* footer() const;
    157     RenderTableSection* firstBody() const;
     155    RenderTableSection* header() const { return m_head.get(); }
     156    RenderTableSection* footer() const { return m_foot.get(); }
     157    RenderTableSection* firstBody() const { return m_firstBody.get(); }
    158158
    159159    // This function returns 0 if the table has no section.
     
    371371};
    372372
     373inline RenderTableSection* RenderTable::topSection() const
     374{
     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
    373383inline bool isDirectionSame(const RenderBox* tableItem, const RenderBox* otherTableItem) { return tableItem && otherTableItem ? tableItem->style().direction() == otherTableItem->style().direction() : true; }
    374384
  • trunk/Source/WebKit/ChangeLog

    r245860 r245863  
     12019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r245857.
     4
     5        Breaks internal builds.
     6
     7        Reverted changeset:
     8
     9        "WeakPtr breaks vtables when upcasting to base classes"
     10        https://bugs.webkit.org/show_bug.cgi?id=188799
     11        https://trac.webkit.org/changeset/245857
     12
    1132019-05-29  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r245857 r245863  
    10171017}
    10181018
    1019 NetworkSession* WebResourceLoadStatisticsStore::networkSession()
    1020 {
    1021     return m_networkSession.get();
    1022 }
    1023 
    10241019void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domainsToRemoveWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
    10251020{
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r245857 r245863  
    176176    void notifyResourceLoadStatisticsProcessed();
    177177
    178     NetworkSession* networkSession();
     178    NetworkSession* networkSession() { return m_networkSession.get(); }
    179179
    180180    void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const;
  • trunk/Source/WebKit/Shared/WebBackForwardListItem.cpp

    r245857 r245863  
    169169}
    170170
    171 SuspendedPageProxy* WebBackForwardListItem::suspendedPage() const
    172 {
    173     return m_suspendedPage.get();
    174 }
    175 
    176171void WebBackForwardListItem::removeSuspendedPageFromProcessPool()
    177172{
  • trunk/Source/WebKit/Shared/WebBackForwardListItem.h

    r245857 r245863  
    7676#endif
    7777    void setSuspendedPage(SuspendedPageProxy*);
    78     SuspendedPageProxy* suspendedPage() const;
     78    SuspendedPageProxy* suspendedPage() const { return m_suspendedPage.get(); }
    7979
    8080#if !LOG_DISABLED
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp

    r245857 r245863  
    2525#include "WebKitURIRequest.h"
    2626#include "WebKitWebResourcePrivate.h"
    27 #include "WebPageProxy.h"
    2827#include <glib/gi18n-lib.h>
    2928#include <wtf/glib/GRefPtr.h>
  • trunk/Source/WebKit/UIProcess/Authentication/cocoa/SecKeyProxyStore.h

    r245857 r245863  
    4040namespace WebKit {
    4141
    42 class SecKeyProxyStore : public RefCounted<SecKeyProxyStore>, public CanMakeWeakPtr<SecKeyProxyStore> {
     42class SecKeyProxyStore : public RefCounted<SecKeyProxyStore> {
    4343public:
    4444    static Ref<SecKeyProxyStore> create() { return adoptRef(* new SecKeyProxyStore()); }
     
    4848
    4949    auto* get() const { return m_secKeyProxy.get(); }
     50    auto& weakPtrFactory() const { return m_weakPtrFactory; }
    5051
    5152private:
    5253    SecKeyProxyStore() = default;
    5354
     55    WeakPtrFactory<SecKeyProxyStore> m_weakPtrFactory;
    5456    RetainPtr<SecKeyProxy> m_secKeyProxy;
    5557};
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h

    r245857 r245863  
    5050
    5151    using AuthenticatorTransportService::Observer::weakPtrFactory;
    52     typedef AuthenticatorTransportService::Observer::WeakValueType WeakValueType;
    5352
    5453    AuthenticatorManager();
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r245857 r245863  
    15141514}
    15151515
    1516 WebProcessPool& WebProcessProxy::processPool() const
    1517 {
    1518     ASSERT(m_processPool);
    1519     return *m_processPool.get();
    1520 }
    1521 
    15221516#if PLATFORM(WATCHOS)
    15231517
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r245857 r245863  
    120120    void decrementSuspendedPageCount();
    121121
    122     WebProcessPool& processPool() const;
     122    WebProcessPool& processPool() const { ASSERT(m_processPool); return *m_processPool.get(); }
    123123
    124124    WebCore::RegistrableDomain registrableDomain() const { return m_registrableDomain.valueOr(WebCore::RegistrableDomain { }); }
  • trunk/Tools/ChangeLog

    r245857 r245863  
     12019-05-29  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r245857.
     4
     5        Breaks internal builds.
     6
     7        Reverted changeset:
     8
     9        "WeakPtr breaks vtables when upcasting to base classes"
     10        https://bugs.webkit.org/show_bug.cgi?id=188799
     11        https://trac.webkit.org/changeset/245857
     12
    1132019-05-28  Geoffrey Garen  <ggaren@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp

    r245857 r245863  
    2626#include "config.h"
    2727
    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 
    3828#include "Test.h"
    3929#include <wtf/HashSet.h>
     
    4131#include <wtf/WeakPtr.h>
    4232
     33static unsigned s_baseWeakReferences = 0;
     34
    4335namespace TestWebKitAPI {
    4436
    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> {
     37class Base {
    5338public:
    5439    Base() { }
     
    5944    }
    6045
    61     int dummy; // Prevent empty base class optimization, to make testing more interesting.
     46    auto& weakPtrFactory() const { return m_weakPtrFactory; }
     47
     48private:
     49    WeakPtrFactory<Base> m_weakPtrFactory;
    6250};
    6351
     
    6654    Derived() { }
    6755
    68     virtual ~Derived() { } // Force a pointer fixup when casting Base <-> Derived
    69 
    7056    int foo()
    7157    {
     
    7662}
    7763
     64namespace WTF {
     65
     66template<>
     67WeakReference<TestWebKitAPI::Base>::WeakReference(TestWebKitAPI::Base* ptr)
     68    : m_ptr(ptr)
     69{
     70    ++s_baseWeakReferences;
     71}
     72template<>
     73WeakReference<TestWebKitAPI::Base>::~WeakReference()
     74{
     75    --s_baseWeakReferences;
     76}
     77
     78}
     79
    7880namespace TestWebKitAPI {
    7981
    8082TEST(WTF_WeakPtr, Basic)
    8183{
    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);
     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);
    8789    EXPECT_EQ(weakPtr1.get(), &dummy);
    8890    EXPECT_EQ(weakPtr2.get(), &dummy);
     
    105107TEST(WTF_WeakPtr, Assignment)
    106108{
    107     Int dummy(5);
    108     WeakPtr<Int> weakPtr;
    109     {
    110         WeakPtrFactory<Int> factory;
     109    int dummy = 5;
     110    WeakPtr<int> weakPtr;
     111    {
     112        WeakPtrFactory<int> factory;
    111113        EXPECT_NULL(weakPtr.get());
    112114        weakPtr = factory.createWeakPtr(dummy);
     
    118120TEST(WTF_WeakPtr, MultipleFactories)
    119121{
    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);
     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);
    126128    EXPECT_EQ(weakPtr1.get(), &dummy1);
    127129    EXPECT_EQ(weakPtr2.get(), &dummy2);
     
    138140TEST(WTF_WeakPtr, RevokeAll)
    139141{
    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);
     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);
    145147    EXPECT_EQ(weakPtr1.get(), &dummy);
    146148    EXPECT_EQ(weakPtr2.get(), &dummy);
     
    152154}
    153155
    154 struct Foo : public CanMakeWeakPtr<Foo> {
     156struct Foo {
    155157    void bar() { };
    156158};
     
    184186TEST(WTF_WeakPtr, Forget)
    185187{
    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;
     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;
    193195        weakPtr1 = innerFactory.createWeakPtr(dummy);
    194196        weakPtr2 = innerFactory.createWeakPtr(dummy);
     
    216218        EXPECT_EQ(weakPtr4.get(), &dummy);
    217219
    218         WeakPtr<Int> weakPtr5 = weakPtr2;
     220        WeakPtr<int> weakPtr5 = weakPtr2;
    219221        EXPECT_EQ(weakPtr2.get(), &dummy);
    220222        EXPECT_EQ(weakPtr5.get(), &dummy);
     
    232234    EXPECT_EQ(weakPtr4.get(), &dummy2);
    233235
    234     WeakPtr<Int> weakPtr5 = weakPtr4;
     236    WeakPtr<int> weakPtr5 = weakPtr4;
    235237    EXPECT_EQ(weakPtr4.get(), &dummy2);
    236238    EXPECT_EQ(weakPtr5.get(), &dummy2);
    237239    weakPtr5.clear();
    238240    EXPECT_NULL(weakPtr5.get());
    239     WeakPtr<Int> weakPtr6 = weakPtr5;
     241    WeakPtr<int> weakPtr6 = weakPtr5;
    240242    EXPECT_NULL(weakPtr6.get());
    241243    EXPECT_EQ(weakPtr5.get(), weakPtr6.get());
    242244
    243     WeakPtr<Int> weakPtr7 = outerFactory.createWeakPtr(dummy2);
     245    WeakPtr<int> weakPtr7 = outerFactory.createWeakPtr(dummy2);
    244246    EXPECT_EQ(weakPtr7.get(), &dummy2);
    245247    weakPtr7 = nullptr;
     
    249251TEST(WTF_WeakPtr, Downcasting)
    250252{
    251     int dummy0(0);
    252     int dummy1(1);
     253    int dummy0 = 0;
     254    int dummy1 = 1;
    253255
    254256    WeakPtr<Base> baseWeakPtr;
Note: See TracChangeset for help on using the changeset viewer.