Title: [135545] trunk/Source/WebCore
Revision
135545
Author
[email protected]
Date
2012-11-22 14:55:35 -0800 (Thu, 22 Nov 2012)

Log Message

[V8] fix DOMWrapperWorld destructor
https://bugs.webkit.org/show_bug.cgi?id=103066

Patch by Dan Carney <[email protected]> on 2012-11-22
Reviewed by Jochen Eisinger.

DOMWrapperWorld had a workaround in place during deletion.
This patch brings it in line with WebKit standards.

No new tests: refactor.

* bindings/v8/DOMWrapperWorld.cpp:
(WebCore::DOMWrapperWorld::~DOMWrapperWorld):
(WebCore::DOMWrapperWorld::ensureIsolatedWorld):
* bindings/v8/DOMWrapperWorld.h:
(DOMWrapperWorld):
(WebCore::DOMWrapperWorld::isolatedWorldDOMDataStore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135544 => 135545)


--- trunk/Source/WebCore/ChangeLog	2012-11-22 22:45:59 UTC (rev 135544)
+++ trunk/Source/WebCore/ChangeLog	2012-11-22 22:55:35 UTC (rev 135545)
@@ -1,3 +1,22 @@
+2012-11-22  Dan Carney  <[email protected]>
+
+        [V8] fix DOMWrapperWorld destructor
+        https://bugs.webkit.org/show_bug.cgi?id=103066
+
+        Reviewed by Jochen Eisinger.
+
+        DOMWrapperWorld had a workaround in place during deletion.
+        This patch brings it in line with WebKit standards.
+
+        No new tests: refactor.
+
+        * bindings/v8/DOMWrapperWorld.cpp:
+        (WebCore::DOMWrapperWorld::~DOMWrapperWorld):
+        (WebCore::DOMWrapperWorld::ensureIsolatedWorld):
+        * bindings/v8/DOMWrapperWorld.h:
+        (DOMWrapperWorld):
+        (WebCore::DOMWrapperWorld::isolatedWorldDOMDataStore):
+
 2012-11-22  Antti Koivisto  <[email protected]>
 
         Remove SVGShadowText class

Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp (135544 => 135545)


--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp	2012-11-22 22:45:59 UTC (rev 135544)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp	2012-11-22 22:55:35 UTC (rev 135545)
@@ -80,29 +80,24 @@
         worlds.append(it->value);
 }
 
-void DOMWrapperWorld::deallocate(DOMWrapperWorld* world)
+DOMWrapperWorld::~DOMWrapperWorld()
 {
-    int worldId = world->worldId();
+    ASSERT(!isMainWorld());
 
-    // Ensure we never deallocate mainThreadNormalWorld
-    if (worldId == mainWorldId)
+    if (!isIsolatedWorld())
         return;
 
-    delete world;
-
-    if (worldId == uninitializedWorldId)
-        return;
-
     WorldMap& map = isolatedWorldMap();
-    WorldMap::iterator i = map.find(worldId);
+    WorldMap::iterator i = map.find(m_worldId);
     if (i == map.end()) {
         ASSERT_NOT_REACHED();
         return;
     }
-    ASSERT(i->value == world);
+    ASSERT(i->value == this);
 
     map.remove(i);
     isolatedWorldCount--;
+    ASSERT(map.size() == isolatedWorldCount);
 }
 
 static int temporaryWorldId = DOMWrapperWorld::uninitializedWorldId-1;
@@ -126,6 +121,8 @@
     RefPtr<DOMWrapperWorld> world = adoptRef(new DOMWrapperWorld(worldId, extensionGroup));
     map.add(worldId, world.get());
     isolatedWorldCount++;
+    ASSERT(map.size() == isolatedWorldCount);
+
     return world.release();
 }
 

Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h (135544 => 135545)


--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h	2012-11-22 22:45:59 UTC (rev 135544)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h	2012-11-22 22:55:35 UTC (rev 135545)
@@ -42,7 +42,7 @@
 class DOMDataStore;
 
 // This class represent a collection of DOM wrappers for a specific world.
-class DOMWrapperWorld : public WTF::RefCountedBase {
+class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
 public:
     static const int mainWorldId = 0;
     static const int mainWorldExtensionGroup = 0;
@@ -50,6 +50,8 @@
     static const int uninitializedExtensionGroup = -1;
     // If uninitializedWorldId is passed as worldId, the world will be assigned a temporary id instead.
     static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int extensionGroup);
+    ~DOMWrapperWorld();
+
     static bool isolatedWorldsExist() { return isolatedWorldCount; }
     static bool isIsolatedWorldId(int worldId) { return worldId != mainWorldId && worldId != uninitializedWorldId; }
     static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds);
@@ -85,16 +87,10 @@
         ASSERT(isIsolatedWorld());
         return m_domDataStore.get();
     }
-    void deref()
-    {
-        if (derefBase())
-            deallocate(this);
-    }
 
 private:
     static int isolatedWorldCount;
     static PassRefPtr<DOMWrapperWorld> createMainWorld();
-    static void deallocate(DOMWrapperWorld*);
 
     DOMWrapperWorld(int worldId, int extensionGroup);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to