Title: [133633] trunk/Source/WebCore
Revision
133633
Author
[email protected]
Date
2012-11-06 10:19:48 -0800 (Tue, 06 Nov 2012)

Log Message

ScriptWrappable should work for more than just Node
https://bugs.webkit.org/show_bug.cgi?id=101319

Reviewed by Eric Seidel.

This patch generalizes the inline cached wrapper code path to work with
all subclasses of ScriptWrappable, not just Node.

* bindings/js/JSDOMBinding.h:
(WebCore::setInlineCachedWrapper):
(WebCore::getInlineCachedWrapper):
(WebCore):
(WebCore::clearInlineCachedWrapper):
(WebCore::cacheWrapper):
* bindings/js/JSNodeCustom.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133632 => 133633)


--- trunk/Source/WebCore/ChangeLog	2012-11-06 18:17:36 UTC (rev 133632)
+++ trunk/Source/WebCore/ChangeLog	2012-11-06 18:19:48 UTC (rev 133633)
@@ -1,3 +1,21 @@
+2012-11-06  Adam Barth  <[email protected]>
+
+        ScriptWrappable should work for more than just Node
+        https://bugs.webkit.org/show_bug.cgi?id=101319
+
+        Reviewed by Eric Seidel.
+
+        This patch generalizes the inline cached wrapper code path to work with
+        all subclasses of ScriptWrappable, not just Node.
+
+        * bindings/js/JSDOMBinding.h:
+        (WebCore::setInlineCachedWrapper):
+        (WebCore::getInlineCachedWrapper):
+        (WebCore):
+        (WebCore::clearInlineCachedWrapper):
+        (WebCore::cacheWrapper):
+        * bindings/js/JSNodeCustom.h:
+
 2012-11-06  Tiancheng Jiang  <[email protected]>
 
         [BlackBerry] Update BB10 form theme.

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (133632 => 133633)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2012-11-06 18:17:36 UTC (rev 133632)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2012-11-06 18:19:48 UTC (rev 133633)
@@ -32,6 +32,7 @@
 #include "Document.h"
 #include "Element.h"
 #include "MediaList.h"
+#include "ScriptWrappable.h"
 #include "StylePropertySet.h"
 #include "StyledElement.h"
 #include <heap/Weak.h>
@@ -129,11 +130,33 @@
         return JSC::jsCast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec, JSC::jsCast<JSDOMGlobalObject*>(globalObject))->storedPrototype()));
     }
 
-    // Overload these functions to provide a fast path for wrapper access.
     inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld*, void*) { return 0; }
-    inline bool setInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*) { return false; }
+    inline bool setInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*, JSC::WeakHandleOwner*, void*) { return false; }
     inline bool clearInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*) { return false; }
 
+    inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld* world, ScriptWrappable* domObject)
+    {
+        if (!world->isNormal())
+            return 0;
+        return domObject->wrapper();
+    }
+
+    inline bool setInlineCachedWrapper(DOMWrapperWorld* world, ScriptWrappable* domObject, JSDOMWrapper* wrapper, JSC::WeakHandleOwner* wrapperOwner, void* context)
+    {
+        if (!world->isNormal())
+            return false;
+        domObject->setWrapper(*world->globalData(), wrapper, wrapperOwner, context);
+        return true;
+    }
+
+    inline bool clearInlineCachedWrapper(DOMWrapperWorld* world, ScriptWrappable* domObject, JSDOMWrapper* wrapper)
+    {
+        if (!world->isNormal())
+            return false;
+        domObject->clearWrapper(wrapper);
+        return true;
+    }
+
     template <typename DOMClass> inline JSDOMWrapper* getCachedWrapper(DOMWrapperWorld* world, DOMClass* domObject)
     {
         if (JSDOMWrapper* wrapper = getInlineCachedWrapper(world, domObject))
@@ -143,9 +166,11 @@
 
     template <typename DOMClass> inline void cacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, JSDOMWrapper* wrapper)
     {
-        if (setInlineCachedWrapper(world, domObject, wrapper))
+        JSC::WeakHandleOwner* owner = wrapperOwner(world, domObject);
+        void* context = wrapperContext(world, domObject);
+        if (setInlineCachedWrapper(world, domObject, wrapper, owner, context))
             return;
-        JSC::PassWeak<JSDOMWrapper> passWeak(wrapper, wrapperOwner(world, domObject), wrapperContext(world, domObject));
+        JSC::PassWeak<JSDOMWrapper> passWeak(wrapper, owner, context);
         weakAdd(world->m_wrappers, (void*)domObject, passWeak);
     }
 

Modified: trunk/Source/WebCore/bindings/js/JSNodeCustom.h (133632 => 133633)


--- trunk/Source/WebCore/bindings/js/JSNodeCustom.h	2012-11-06 18:17:36 UTC (rev 133632)
+++ trunk/Source/WebCore/bindings/js/JSNodeCustom.h	2012-11-06 18:19:48 UTC (rev 133633)
@@ -32,29 +32,6 @@
 
 namespace WebCore {
 
-inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld* world, Node* node)
-{
-    if (!world->isNormal())
-        return 0;
-    return node->wrapper();
-}
-
-inline bool setInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrapper* wrapper)
-{
-    if (!world->isNormal())
-        return false;
-    node->setWrapper(*world->globalData(), wrapper, wrapperOwner(world, node), wrapperContext(world, node));
-    return true;
-}
-
-inline bool clearInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrapper* wrapper)
-{
-    if (!world->isNormal())
-        return false;
-    node->clearWrapper(wrapper);
-    return true;
-}
-
 JSC::JSValue createWrapper(JSC::ExecState*, JSDOMGlobalObject*, Node*);
 
 inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Node* node)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to