Title: [126465] trunk/Source/WebCore
Revision
126465
Author
aba...@webkit.org
Date
2012-08-23 12:16:46 -0700 (Thu, 23 Aug 2012)

Log Message

[V8] V8ScriptInstance is much more complicated than necessary
https://bugs.webkit.org/show_bug.cgi?id=94785

Reviewed by Kentaro Hara.

V8ScriptInstance just needs to be a one-line wrapper around OwnHandle.

* bindings/v8/OwnHandle.h:
(WebCore::OwnHandle::get):
* bindings/v8/ScriptInstance.cpp:
(WebCore::V8ScriptInstance::V8ScriptInstance):
(WebCore::V8ScriptInstance::~V8ScriptInstance):
(WebCore::V8ScriptInstance::instance):
* bindings/v8/ScriptInstance.h:
(WebCore::V8ScriptInstance::create):
(V8ScriptInstance):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126464 => 126465)


--- trunk/Source/WebCore/ChangeLog	2012-08-23 19:08:54 UTC (rev 126464)
+++ trunk/Source/WebCore/ChangeLog	2012-08-23 19:16:46 UTC (rev 126465)
@@ -1,3 +1,22 @@
+2012-08-23  Adam Barth  <aba...@webkit.org>
+
+        [V8] V8ScriptInstance is much more complicated than necessary
+        https://bugs.webkit.org/show_bug.cgi?id=94785
+
+        Reviewed by Kentaro Hara.
+
+        V8ScriptInstance just needs to be a one-line wrapper around OwnHandle.
+
+        * bindings/v8/OwnHandle.h:
+        (WebCore::OwnHandle::get):
+        * bindings/v8/ScriptInstance.cpp:
+        (WebCore::V8ScriptInstance::V8ScriptInstance):
+        (WebCore::V8ScriptInstance::~V8ScriptInstance):
+        (WebCore::V8ScriptInstance::instance):
+        * bindings/v8/ScriptInstance.h:
+        (WebCore::V8ScriptInstance::create):
+        (V8ScriptInstance):
+
 2012-08-23  Christophe Dumez  <christophe.du...@intel.com>
 
         Serialization of _javascript_ values does not appear to respect new HTML5 Structured Clone semantics

Modified: trunk/Source/WebCore/bindings/v8/OwnHandle.h (126464 => 126465)


--- trunk/Source/WebCore/bindings/v8/OwnHandle.h	2012-08-23 19:08:54 UTC (rev 126464)
+++ trunk/Source/WebCore/bindings/v8/OwnHandle.h	2012-08-23 19:16:46 UTC (rev 126465)
@@ -52,7 +52,7 @@
         clear();
     }
 
-    v8::Handle<T> get() const { return m_handle; }
+    v8::Persistent<T> get() const { return m_handle; }
 
     void set(v8::Handle<T> handle)
     {

Modified: trunk/Source/WebCore/bindings/v8/ScriptInstance.cpp (126464 => 126465)


--- trunk/Source/WebCore/bindings/v8/ScriptInstance.cpp	2012-08-23 19:08:54 UTC (rev 126464)
+++ trunk/Source/WebCore/bindings/v8/ScriptInstance.cpp	2012-08-23 19:16:46 UTC (rev 126465)
@@ -31,51 +31,11 @@
 #include "config.h"
 #include "ScriptInstance.h"
 
-#include "V8GCController.h"
-#include <wtf/Assertions.h>
-
 namespace WebCore {
 
-V8ScriptInstance::V8ScriptInstance()
-{
-}
-
 V8ScriptInstance::V8ScriptInstance(v8::Handle<v8::Object> instance)
+    : m_instance(instance)
 {
-    set(instance);
 }
 
-V8ScriptInstance::~V8ScriptInstance()
-{
-    clear();
-}
-
-v8::Persistent<v8::Object> V8ScriptInstance::instance()
-{
-    return m_instance;
-}
-
-void V8ScriptInstance::clear()
-{
-    if (m_instance.IsEmpty())
-        return;
-#ifndef NDEBUG
-    V8GCController::unregisterGlobalHandle(this, m_instance);
-#endif
-    m_instance.Dispose();
-    m_instance.Clear();
-}
-
-void V8ScriptInstance::set(v8::Handle<v8::Object> instance)
-{
-    clear();
-    if (instance.IsEmpty())
-        return;
-
-    m_instance = v8::Persistent<v8::Object>::New(instance);
-#ifndef NDEBUG
-    V8GCController::registerGlobalHandle(SCRIPTINSTANCE, this, m_instance);
-#endif
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/ScriptInstance.h (126464 => 126465)


--- trunk/Source/WebCore/bindings/v8/ScriptInstance.h	2012-08-23 19:08:54 UTC (rev 126464)
+++ trunk/Source/WebCore/bindings/v8/ScriptInstance.h	2012-08-23 19:16:46 UTC (rev 126465)
@@ -31,8 +31,8 @@
 #ifndef ScriptInstance_h
 #define ScriptInstance_h
 
+#include "OwnHandle.h"
 #include <v8.h>
-
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -41,19 +41,14 @@
 
 class V8ScriptInstance : public RefCounted<V8ScriptInstance> {
 public:
-    static PassRefPtr<V8ScriptInstance> create(v8::Handle<v8::Object> instance)
-    {
-        return adoptRef(new V8ScriptInstance(instance));
-    }
-    V8ScriptInstance();
-    V8ScriptInstance(v8::Handle<v8::Object>);
-    ~V8ScriptInstance();
-    v8::Persistent<v8::Object> instance();
+    static PassRefPtr<V8ScriptInstance> create(v8::Handle<v8::Object> instance) { return adoptRef(new V8ScriptInstance(instance)); }
 
+    v8::Persistent<v8::Object> instance() { return m_instance.get(); }
+
 private:
-    void clear();
-    void set(v8::Handle<v8::Object>);
-    mutable v8::Persistent<v8::Object> m_instance;
+    explicit V8ScriptInstance(v8::Handle<v8::Object>);
+
+    OwnHandle<v8::Object> m_instance;
 };
 
 typedef RefPtr<V8ScriptInstance> ScriptInstance;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to