Title: [206661] trunk/Source/WebCore
Revision
206661
Author
[email protected]
Date
2016-09-30 13:52:02 -0700 (Fri, 30 Sep 2016)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206660 => 206661)


--- trunk/Source/WebCore/ChangeLog	2016-09-30 20:47:51 UTC (rev 206660)
+++ trunk/Source/WebCore/ChangeLog	2016-09-30 20:52:02 UTC (rev 206661)
@@ -1,3 +1,23 @@
+2016-09-30  Zalan Bujtas  <[email protected]>
+
+        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.
+
 2016-09-30  Chris Dumez  <[email protected]>
 
         FileSaver.js does not work in WebKit

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (206660 => 206661)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2016-09-30 20:47:51 UTC (rev 206660)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2016-09-30 20:52:02 UTC (rev 206661)
@@ -137,7 +137,7 @@
 
 using namespace HTMLNames;
 
-class ClipRects {
+class ClipRects : public RefCounted<ClipRects> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     static Ref<ClipRects> create()
@@ -150,8 +150,6 @@
         return adoptRef(*new ClipRects(other));
     }
 
-    ClipRects() = default;
-
     void reset()
     {
         m_overflowClipRect.reset();
@@ -172,13 +170,6 @@
     bool fixed() const { return m_fixed; }
     void setFixed(bool fixed) { m_fixed = fixed; }
 
-    void ref() { m_refCount++; }
-    void deref()
-    {
-        if (!--m_refCount)
-            delete this;
-    }
-
     bool operator==(const ClipRects& other) const
     {
         return m_overflowClipRect == other.overflowClipRect()
@@ -197,6 +188,8 @@
     }
 
 private:
+    ClipRects() = default;
+
     ClipRects(const LayoutRect& clipRect)
         : m_overflowClipRect(clipRect)
         , m_fixedClipRect(clipRect)
@@ -205,18 +198,17 @@
     }
 
     ClipRects(const ClipRects& other)
-        : m_overflowClipRect(other.overflowClipRect())
+        : m_fixed(other.fixed())
+        , m_overflowClipRect(other.overflowClipRect())
         , m_fixedClipRect(other.fixedClipRect())
         , m_posClipRect(other.posClipRect())
-        , m_fixed(other.fixed())
     {
     }
 
+    bool m_fixed { false };
     ClipRect m_overflowClipRect;
     ClipRect m_fixedClipRect;
     ClipRect m_posClipRect;
-    unsigned m_refCount = 1;
-    bool m_fixed = false;
 };
 
 class ClipRectsCache {
@@ -232,9 +224,16 @@
 #endif
     }
 
-    ClipRects* getClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow) { return m_clipRects[getIndex(clipRectsType, respectOverflow)].get(); }
-    void setClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow, RefPtr<ClipRects>&& clipRects) { m_clipRects[getIndex(clipRectsType, respectOverflow)] = WTFMove(clipRects); }
+    ClipRects* getClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow) const
+    {
+        return m_clipRects[getIndex(clipRectsType, respectOverflow)].get();
+    }
 
+    void setClipRects(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow, RefPtr<ClipRects>&& clipRects)
+    {
+        m_clipRects[getIndex(clipRectsType, respectOverflow)] = WTFMove(clipRects);
+    }
+
 #ifndef NDEBUG
     const RenderLayer* m_clipRectsRoot[NumCachedClipRectsTypes];
     OverlayScrollbarSizeRelevancy m_scrollbarRelevancy[NumCachedClipRectsTypes];
@@ -241,11 +240,12 @@
 #endif
 
 private:
-    int getIndex(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow)
+    unsigned getIndex(ClipRectsType clipRectsType, ShouldRespectOverflowClip respectOverflow) const
     {
-        int index = static_cast<int>(clipRectsType);
+        unsigned index = static_cast<unsigned>(clipRectsType);
         if (respectOverflow == RespectOverflowClip)
-            index += static_cast<int>(NumCachedClipRectsTypes);
+            index += static_cast<unsigned>(NumCachedClipRectsTypes);
+        ASSERT_WITH_SECURITY_IMPLICATION(index < NumCachedClipRectsTypes * 2);
         return index;
     }
 
@@ -5418,9 +5418,9 @@
             // This code is useful to check cached clip rects, but is too expensive to leave enabled in debug builds by default.
             ClipRectsContext tempContext(clipRectsContext);
             tempContext.clipRectsType = TemporaryClipRects;
-            ClipRects tempClipRects;
+            Ref<ClipRects> tempClipRects = ClipRects::create();
             calculateClipRects(tempContext, tempClipRects);
-            ASSERT(tempClipRects == *clipRects);
+            ASSERT(tempClipRects.get() == *clipRects);
 #endif
             return *clipRects; // We have the correct cached value.
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to