Changeset 206661 in webkit


Ignore:
Timestamp:
Sep 30, 2016 1:52:02 PM (8 years ago)
Author:
Alan Bujtas
Message:

Remove ClipRects's custom refcounting.
https://bugs.webkit.org/show_bug.cgi?id=162798

Reviewed by Simon Fraser.

It's safer to use RefCounted<>.

No change in functionality.

  • rendering/RenderLayer.cpp:

(WebCore::ClipRects::ClipRects):
(WebCore::ClipRectsCache::getClipRects):
(WebCore::ClipRectsCache::setClipRects):
(WebCore::ClipRectsCache::getIndex):
(WebCore::RenderLayer::updateClipRects):
(WebCore::ClipRects::ref): Deleted.
(WebCore::ClipRects::deref): Deleted.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206659 r206661  
     12016-09-30  Zalan Bujtas  <zalan@apple.com>
     2
     3        Remove ClipRects's custom refcounting.
     4        https://bugs.webkit.org/show_bug.cgi?id=162798
     5
     6        Reviewed by Simon Fraser.
     7
     8        It's safer to use RefCounted<>.
     9
     10        No change in functionality.
     11
     12        * rendering/RenderLayer.cpp:
     13        (WebCore::ClipRects::ClipRects):
     14        (WebCore::ClipRectsCache::getClipRects):
     15        (WebCore::ClipRectsCache::setClipRects):
     16        (WebCore::ClipRectsCache::getIndex):
     17        (WebCore::RenderLayer::updateClipRects):
     18        (WebCore::ClipRects::ref): Deleted.
     19        (WebCore::ClipRects::deref): Deleted.
     20
    1212016-09-30  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r206639 r206661  
    138138using namespace HTMLNames;
    139139
    140 class ClipRects {
     140class ClipRects : public RefCounted<ClipRects> {
    141141    WTF_MAKE_FAST_ALLOCATED;
    142142public:
     
    150150        return adoptRef(*new ClipRects(other));
    151151    }
    152 
    153     ClipRects() = default;
    154152
    155153    void reset()
     
    172170    bool fixed() const { return m_fixed; }
    173171    void setFixed(bool fixed) { m_fixed = fixed; }
    174 
    175     void ref() { m_refCount++; }
    176     void deref()
    177     {
    178         if (!--m_refCount)
    179             delete this;
    180     }
    181172
    182173    bool operator==(const ClipRects& other) const
     
    198189
    199190private:
     191    ClipRects() = default;
     192
    200193    ClipRects(const LayoutRect& clipRect)
    201194        : m_overflowClipRect(clipRect)
     
    206199
    207200    ClipRects(const ClipRects& other)
    208         : m_overflowClipRect(other.overflowClipRect())
     201        : m_fixed(other.fixed())
     202        , m_overflowClipRect(other.overflowClipRect())
    209203        , m_fixedClipRect(other.fixedClipRect())
    210204        , m_posClipRect(other.posClipRect())
    211         , m_fixed(other.fixed())
    212205    {
    213206    }
    214207
     208    bool m_fixed { false };
    215209    ClipRect m_overflowClipRect;
    216210    ClipRect m_fixedClipRect;
    217211    ClipRect m_posClipRect;
    218     unsigned m_refCount = 1;
    219     bool m_fixed = false;
    220212};
    221213
     
    233225    }
    234226
    235     ClipRects* getClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow) { return m_clipRects[getIndex(clipRectsType, respectOverflow)].get(); }
    236     void setClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow, RefPtr<ClipRects>&& clipRects) { m_clipRects[getIndex(clipRectsType, respectOverflow)] = WTFMove(clipRects); }
     227    ClipRects* getClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow) const
     228    {
     229        return m_clipRects[getIndex(clipRectsType, respectOverflow)].get();
     230    }
     231
     232    void setClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow, RefPtr<ClipRects>&& clipRects)
     233    {
     234        m_clipRects[getIndex(clipRectsType, respectOverflow)] = WTFMove(clipRects);
     235    }
    237236
    238237#ifndef NDEBUG
     
    242241
    243242private:
    244     int getIndex(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow)
     243    unsigned getIndex(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow) const
    245244    {
    246         int index = static_cast<int>(clipRectsType);
     245        unsigned index = static_cast<unsigned>(clipRectsType);
    247246        if (respectOverflow == RespectOverflowClip)
    248             index += static_cast<int>(NumCachedClipRectsTypes);
     247            index += static_cast<unsigned>(NumCachedClipRectsTypes);
     248        ASSERT_WITH_SECURITY_IMPLICATION(index < NumCachedClipRectsTypes * 2);
    249249        return index;
    250250    }
     
    54195419            ClipRectsContext tempContext(clipRectsContext);
    54205420            tempContext.clipRectsType = TemporaryClipRects;
    5421             ClipRects tempClipRects;
     5421            Ref<ClipRects> tempClipRects = ClipRects::create();
    54225422            calculateClipRects(tempContext, tempClipRects);
    5423             ASSERT(tempClipRects == *clipRects);
     5423            ASSERT(tempClipRects.get() == *clipRects);
    54245424#endif
    54255425            return *clipRects; // We have the correct cached value.
Note: See TracChangeset for help on using the changeset viewer.