Changeset 85746 in webkit


Ignore:
Timestamp:
May 4, 2011 7:11:50 AM (13 years ago)
Author:
Adam Roben
Message:

Disallow equality comparisons between [Pass]OwnPtrs

If you have two OwnPtrs that are equal, you've already lost. (Unless you're doing something
really sneaky, in which case you should stop!)

Fixes <http://webkit.org/b/60053> Testing OwnPtrs for equality should cause a compiler error

Reviewed by Anders Carlsson and Antti Koivisto.

Source/JavaScriptCore:

  • wtf/OwnPtr.h:

(WTF::OwnPtr::operator==):
(WTF::OwnPtr::operator!=):

  • wtf/PassOwnPtr.h:

(WTF::PassOwnPtr::operator==):
(WTF::PassOwnPtr::operator!=):
Added private equality operators that fail to compile when used. (When not used, the
compiler will skip over them because they are function templates.)

Source/WebCore:

Remove an unnecessary OwnPtr equality check in XSLT code

  • dom/Document.cpp:

(WebCore::Document::setTransformSource): No need to check for equality. If the pointers are
equal, we're screwed anyway. (And the caller always passes in a newly-allocated object, so
we're safe.)

Source/WebKit2:

Remove WebPageProxy::setDrawingArea

It is unused. It also does a useless equality comparison between OwnPtrs; if they are equal,
we've already lost.

  • UIProcess/WebPageProxy.cpp:
  • UIProcess/WebPageProxy.h:

Removed setDrawingArea.

(WebKit::WebPageProxy::drawingArea):
(WebKit::WebPageProxy::backForwardList):
Made these functions const while I was at it.

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r85729 r85746  
     12011-05-03  Adam Roben  <aroben@apple.com>
     2
     3        Disallow equality comparisons between [Pass]OwnPtrs
     4
     5        If you have two OwnPtrs that are equal, you've already lost. (Unless you're doing something
     6        really sneaky, in which case you should stop!)
     7
     8        Fixes <http://webkit.org/b/60053> Testing OwnPtrs for equality should cause a compiler error
     9
     10        Reviewed by Anders Carlsson and Antti Koivisto.
     11
     12        * wtf/OwnPtr.h:
     13        (WTF::OwnPtr::operator==):
     14        (WTF::OwnPtr::operator!=):
     15        * wtf/PassOwnPtr.h:
     16        (WTF::PassOwnPtr::operator==):
     17        (WTF::PassOwnPtr::operator!=):
     18        Added private equality operators that fail to compile when used. (When not used, the
     19        compiler will skip over them because they are function templates.)
     20
    1212011-05-04  Alexis Menard  <alexis.menard@openbossa.org>
    222
  • trunk/Source/JavaScriptCore/wtf/OwnPtr.h

    r85445 r85746  
    8282    private:
    8383        OwnPtr& operator=(const OwnPtr<T>&);
     84
     85        // We should never have two OwnPtrs for the same underlying object (otherwise we'll get
     86        // double-destruction), so these equality operators should never be needed.
     87        template<typename U> bool operator==(const OwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     88        template<typename U> bool operator!=(const OwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     89        template<typename U> bool operator==(const PassOwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     90        template<typename U> bool operator!=(const PassOwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
    8491
    8592        PtrType m_ptr;
  • trunk/Source/JavaScriptCore/wtf/PassOwnPtr.h

    r85603 r85746  
    9191#endif
    9292
     93        // We should never have two OwnPtrs for the same underlying object (otherwise we'll get
     94        // double-destruction), so these equality operators should never be needed.
     95        template<typename U> bool operator==(const PassOwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     96        template<typename U> bool operator!=(const PassOwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     97        template<typename U> bool operator==(const OwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     98        template<typename U> bool operator!=(const OwnPtr<U>&) { COMPILE_ASSERT(false, OwnPtrs_should_never_be_equal); }
     99
    93100        mutable PtrType m_ptr;
    94101    };
  • trunk/Source/WebCore/ChangeLog

    r85745 r85746  
     12011-05-03  Adam Roben  <aroben@apple.com>
     2
     3        Remove an unnecessary OwnPtr equality check in XSLT code
     4
     5        Fixes <http://webkit.org/b/60053> Testing OwnPtrs for equality should cause a compiler error
     6
     7        Reviewed by Anders Carlsson and Antti Koivisto.
     8
     9        * dom/Document.cpp:
     10        (WebCore::Document::setTransformSource): No need to check for equality. If the pointers are
     11        equal, we're screwed anyway. (And the caller always passes in a newly-allocated object, so
     12        we're safe.)
     13
    1142011-05-04  Leandro Gracia Gil  <leandrogracia@chromium.org>
    215
  • trunk/Source/WebCore/dom/Document.cpp

    r85680 r85746  
    40594059void Document::setTransformSource(PassOwnPtr<TransformSource> source)
    40604060{
    4061     if (m_transformSource == source)
    4062         return;
    40634061    m_transformSource = source;
    40644062}
  • trunk/Source/WebKit2/ChangeLog

    r85721 r85746  
     12011-05-03  Adam Roben  <aroben@apple.com>
     2
     3        Remove WebPageProxy::setDrawingArea
     4
     5        It is unused. It also does a useless equality comparison between OwnPtrs; if they are equal,
     6        we've already lost.
     7
     8        Reviewed by Anders Carlsson and Antti Koivisto.
     9
     10        * UIProcess/WebPageProxy.cpp:
     11        * UIProcess/WebPageProxy.h:
     12        Removed setDrawingArea.
     13
     14        (WebKit::WebPageProxy::drawingArea):
     15        (WebKit::WebPageProxy::backForwardList):
     16        Made these functions const while I was at it.
     17
    1182011-05-03  Pratik Solanki  <psolanki@apple.com>
    219
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r85689 r85746  
    195195}
    196196
    197 void WebPageProxy::setDrawingArea(PassOwnPtr<DrawingAreaProxy> drawingArea)
    198 {
    199     if (drawingArea == m_drawingArea)
    200         return;
    201 
    202     m_drawingArea = drawingArea;
    203 }
    204 
    205197void WebPageProxy::initializeLoaderClient(const WKPageLoaderClient* loadClient)
    206198{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r85502 r85746  
    177177    WebFrameProxy* frameSetLargestFrame() const { return m_frameSetLargestFrame.get(); }
    178178
    179     DrawingAreaProxy* drawingArea() { return m_drawingArea.get(); }
    180     void setDrawingArea(PassOwnPtr<DrawingAreaProxy>);
    181 
    182     WebBackForwardList* backForwardList() { return m_backForwardList.get(); }
     179    DrawingAreaProxy* drawingArea() const { return m_drawingArea.get(); }
     180
     181    WebBackForwardList* backForwardList() const { return m_backForwardList.get(); }
    183182
    184183#if ENABLE(INSPECTOR)
Note: See TracChangeset for help on using the changeset viewer.