Changeset 133633 in webkit


Ignore:
Timestamp:
Nov 6, 2012 10:19:48 AM (11 years ago)
Author:
abarth@webkit.org
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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r133632 r133633  
     12012-11-06  Adam Barth  <abarth@webkit.org>
     2
     3        ScriptWrappable should work for more than just Node
     4        https://bugs.webkit.org/show_bug.cgi?id=101319
     5
     6        Reviewed by Eric Seidel.
     7
     8        This patch generalizes the inline cached wrapper code path to work with
     9        all subclasses of ScriptWrappable, not just Node.
     10
     11        * bindings/js/JSDOMBinding.h:
     12        (WebCore::setInlineCachedWrapper):
     13        (WebCore::getInlineCachedWrapper):
     14        (WebCore):
     15        (WebCore::clearInlineCachedWrapper):
     16        (WebCore::cacheWrapper):
     17        * bindings/js/JSNodeCustom.h:
     18
    1192012-11-06  Tiancheng Jiang  <tijiang@rim.com>
    220
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r129779 r133633  
    3333#include "Element.h"
    3434#include "MediaList.h"
     35#include "ScriptWrappable.h"
    3536#include "StylePropertySet.h"
    3637#include "StyledElement.h"
     
    130131    }
    131132
    132     // Overload these functions to provide a fast path for wrapper access.
    133133    inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld*, void*) { return 0; }
    134     inline bool setInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*) { return false; }
     134    inline bool setInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*, JSC::WeakHandleOwner*, void*) { return false; }
    135135    inline bool clearInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*) { return false; }
     136
     137    inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld* world, ScriptWrappable* domObject)
     138    {
     139        if (!world->isNormal())
     140            return 0;
     141        return domObject->wrapper();
     142    }
     143
     144    inline bool setInlineCachedWrapper(DOMWrapperWorld* world, ScriptWrappable* domObject, JSDOMWrapper* wrapper, JSC::WeakHandleOwner* wrapperOwner, void* context)
     145    {
     146        if (!world->isNormal())
     147            return false;
     148        domObject->setWrapper(*world->globalData(), wrapper, wrapperOwner, context);
     149        return true;
     150    }
     151
     152    inline bool clearInlineCachedWrapper(DOMWrapperWorld* world, ScriptWrappable* domObject, JSDOMWrapper* wrapper)
     153    {
     154        if (!world->isNormal())
     155            return false;
     156        domObject->clearWrapper(wrapper);
     157        return true;
     158    }
    136159
    137160    template <typename DOMClass> inline JSDOMWrapper* getCachedWrapper(DOMWrapperWorld* world, DOMClass* domObject)
     
    144167    template <typename DOMClass> inline void cacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, JSDOMWrapper* wrapper)
    145168    {
    146         if (setInlineCachedWrapper(world, domObject, wrapper))
     169        JSC::WeakHandleOwner* owner = wrapperOwner(world, domObject);
     170        void* context = wrapperContext(world, domObject);
     171        if (setInlineCachedWrapper(world, domObject, wrapper, owner, context))
    147172            return;
    148         JSC::PassWeak<JSDOMWrapper> passWeak(wrapper, wrapperOwner(world, domObject), wrapperContext(world, domObject));
     173        JSC::PassWeak<JSDOMWrapper> passWeak(wrapper, owner, context);
    149174        weakAdd(world->m_wrappers, (void*)domObject, passWeak);
    150175    }
  • trunk/Source/WebCore/bindings/js/JSNodeCustom.h

    r130611 r133633  
    3333namespace WebCore {
    3434
    35 inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld* world, Node* node)
    36 {
    37     if (!world->isNormal())
    38         return 0;
    39     return node->wrapper();
    40 }
    41 
    42 inline bool setInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrapper* wrapper)
    43 {
    44     if (!world->isNormal())
    45         return false;
    46     node->setWrapper(*world->globalData(), wrapper, wrapperOwner(world, node), wrapperContext(world, node));
    47     return true;
    48 }
    49 
    50 inline bool clearInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrapper* wrapper)
    51 {
    52     if (!world->isNormal())
    53         return false;
    54     node->clearWrapper(wrapper);
    55     return true;
    56 }
    57 
    5835JSC::JSValue createWrapper(JSC::ExecState*, JSDOMGlobalObject*, Node*);
    5936
Note: See TracChangeset for help on using the changeset viewer.