Changeset 84194 in webkit


Ignore:
Timestamp:
Apr 18, 2011 3:41:06 PM (13 years ago)
Author:
ggaren@apple.com
Message:

2011-04-18 Geoffrey Garen <ggaren@apple.com>

Reviewed by Oliver Hunt.

Made DOM handle ownership customizable, and customized it for Nodes and NamedAttrMaps
https://bugs.webkit.org/show_bug.cgi?id=58828

  • WebCore.exp.in: Blah.
  • bindings/js/DOMWrapperWorld.cpp: Moved code related to JSNode ownership to JSNodeCustom, where other custom JSNode-related code goes.

(WebCore::JSDOMWrapperOwner::finalize):
(WebCore::DOMWrapperWorld::DOMWrapperWorld):

  • bindings/js/DOMWrapperWorld.h: (WebCore::JSDOMWrapperOwner::JSDOMWrapperOwner): (WebCore::DOMWrapperWorld::defaultWrapperOwner): Renamed DOMObjectHandleOwner to JSDOMWrapperOwner, to match the name of JSDOMWrapper.
  • bindings/js/JSArrayBufferViewHelper.h: (WebCore::toJSArrayBufferView):
  • bindings/js/JSCSSRuleCustom.cpp: (WebCore::toJS):
  • bindings/js/JSCSSValueCustom.cpp: (WebCore::toJS):
  • bindings/js/JSCanvasRenderingContextCustom.cpp: (WebCore::toJS): Removed "DOMObject" and "Node" from the names of wrapper- related functions, since there is no meaningful distinction between the two anymore -- they both use the same extensible interface.


  • bindings/js/JSDOMBinding.cpp: Removed some now-unused functions.
  • bindings/js/JSDOMBinding.h: (WebCore::getInlineCachedWrapper): (WebCore::setInlineCachedWrapper): (WebCore::clearInlineCachedWrapper): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::getCachedWrapper): (WebCore::cacheWrapper): (WebCore::uncacheWrapper): (WebCore::createWrapper): (WebCore::wrap): Created a generic, extensible mechanism for creating, caching, retrieving, marking, and destroying DOM wrappers. This eliminates the difference between DOM object wrappers and DOM node wrappers, and lays the groundwork for getting rid of MarkStack::deprecatedAppend usage for marking the remainder of our DOM objects.


  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::history): (WebCore::JSDOMWindow::location):
  • bindings/js/JSDataViewCustom.cpp: (WebCore::toJS):
  • bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::location): (WebCore::toJS):
  • bindings/js/JSElementCustom.cpp: (WebCore::toJSNewlyCreated):
  • bindings/js/JSEventCustom.cpp: (WebCore::toJS):
  • bindings/js/JSHTMLCollectionCustom.cpp: (WebCore::toJS):
  • bindings/js/JSImageDataCustom.cpp: (WebCore::toJS): Updated for renames mentioned above.
  • bindings/js/JSNamedNodeMapCustom.cpp: (WebCore::JSNamedNodeMapOwner::isReachableFromOpaqueRoots): (WebCore::JSNamedNodeMapOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::JSNamedNodeMap::markChildren): (WebCore::toJS): Updated to use our new interface for customizing wrapper lifetime management through function overloading without using MarkStack::deprecatedAppend.
  • bindings/js/JSNodeCustom.cpp: (WebCore::isObservable): (WebCore::isReachableFromDOM): (WebCore::JSNodeOwner::isReachableFromOpaqueRoots): (WebCore::JSNodeOwner::finalize): (WebCore::createWrapperInline): Moved node-related code from JSDOMBinding to here. Removed special case marking code for JSNamedNodeMap because JSNamedNodeMap now knows how to maintain its own lifetime invariants.
  • bindings/js/JSNodeCustom.h: (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::getInlineCachedWrapper): (WebCore::setInlineCachedWrapper): (WebCore::clearInlineCachedWrapper): (WebCore::toJS): Updated to use our new interface for customizing wrapper lifetime management through function overloading without using MarkStack::deprecatedAppend or special-case code for nodes.


  • bindings/js/JSSVGPathSegCustom.cpp: (WebCore::toJS):
  • bindings/js/JSStyleSheetCustom.cpp: (WebCore::toJS): Updated for renames mentioned above.
  • bindings/scripts/CodeGeneratorJS.pm: Fixed up newlines. Updated for renames mentioned above.
  • dom/NamedNodeMap.idl: NamedNodeMap needs a custom toJS function now because it needs to provide a custom WeakHandleOwner at wrapper creation time.
Location:
trunk/Source/WebCore
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84192 r84194  
     12011-04-18  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Made DOM handle ownership customizable, and customized it for Nodes and NamedAttrMaps
     6        https://bugs.webkit.org/show_bug.cgi?id=58828
     7
     8        * WebCore.exp.in: Blah.
     9
     10        * bindings/js/DOMWrapperWorld.cpp: Moved code related to JSNode ownership
     11        to JSNodeCustom, where other custom JSNode-related code goes.
     12
     13        (WebCore::JSDOMWrapperOwner::finalize):
     14        (WebCore::DOMWrapperWorld::DOMWrapperWorld):
     15        * bindings/js/DOMWrapperWorld.h:
     16        (WebCore::JSDOMWrapperOwner::JSDOMWrapperOwner):
     17        (WebCore::DOMWrapperWorld::defaultWrapperOwner): Renamed DOMObjectHandleOwner
     18        to JSDOMWrapperOwner, to match the name of JSDOMWrapper.
     19
     20        * bindings/js/JSArrayBufferViewHelper.h:
     21        (WebCore::toJSArrayBufferView):
     22        * bindings/js/JSCSSRuleCustom.cpp:
     23        (WebCore::toJS):
     24        * bindings/js/JSCSSValueCustom.cpp:
     25        (WebCore::toJS):
     26        * bindings/js/JSCanvasRenderingContextCustom.cpp:
     27        (WebCore::toJS): Removed "DOMObject" and "Node" from the names of wrapper-
     28        related functions, since there is no meaningful distinction between the
     29        two anymore -- they both use the same extensible interface.
     30       
     31        * bindings/js/JSDOMBinding.cpp: Removed some now-unused functions.
     32
     33        * bindings/js/JSDOMBinding.h:
     34        (WebCore::getInlineCachedWrapper):
     35        (WebCore::setInlineCachedWrapper):
     36        (WebCore::clearInlineCachedWrapper):
     37        (WebCore::wrapperOwner):
     38        (WebCore::wrapperContext):
     39        (WebCore::getCachedWrapper):
     40        (WebCore::cacheWrapper):
     41        (WebCore::uncacheWrapper):
     42        (WebCore::createWrapper):
     43        (WebCore::wrap): Created a generic, extensible mechanism for creating,
     44        caching, retrieving, marking, and destroying DOM wrappers. This eliminates
     45        the difference between DOM object wrappers and DOM node wrappers, and
     46        lays the groundwork for getting rid of MarkStack::deprecatedAppend usage
     47        for marking the remainder of our DOM objects.
     48       
     49        * bindings/js/JSDOMWindowCustom.cpp:
     50        (WebCore::JSDOMWindow::history):
     51        (WebCore::JSDOMWindow::location):
     52        * bindings/js/JSDataViewCustom.cpp:
     53        (WebCore::toJS):
     54        * bindings/js/JSDocumentCustom.cpp:
     55        (WebCore::JSDocument::location):
     56        (WebCore::toJS):
     57        * bindings/js/JSElementCustom.cpp:
     58        (WebCore::toJSNewlyCreated):
     59        * bindings/js/JSEventCustom.cpp:
     60        (WebCore::toJS):
     61        * bindings/js/JSHTMLCollectionCustom.cpp:
     62        (WebCore::toJS):
     63        * bindings/js/JSImageDataCustom.cpp:
     64        (WebCore::toJS): Updated for renames mentioned above.
     65
     66        * bindings/js/JSNamedNodeMapCustom.cpp:
     67        (WebCore::JSNamedNodeMapOwner::isReachableFromOpaqueRoots):
     68        (WebCore::JSNamedNodeMapOwner::finalize):
     69        (WebCore::wrapperOwner):
     70        (WebCore::wrapperContext):
     71        (WebCore::JSNamedNodeMap::markChildren):
     72        (WebCore::toJS): Updated to use our new interface for customizing wrapper
     73        lifetime management through function overloading without using
     74        MarkStack::deprecatedAppend.
     75
     76        * bindings/js/JSNodeCustom.cpp:
     77        (WebCore::isObservable):
     78        (WebCore::isReachableFromDOM):
     79        (WebCore::JSNodeOwner::isReachableFromOpaqueRoots):
     80        (WebCore::JSNodeOwner::finalize):
     81        (WebCore::createWrapperInline): Moved node-related code from JSDOMBinding
     82        to here. Removed special case marking code for JSNamedNodeMap because
     83        JSNamedNodeMap now knows how to maintain its own lifetime invariants.
     84
     85        * bindings/js/JSNodeCustom.h:
     86        (WebCore::wrapperOwner):
     87        (WebCore::wrapperContext):
     88        (WebCore::getInlineCachedWrapper):
     89        (WebCore::setInlineCachedWrapper):
     90        (WebCore::clearInlineCachedWrapper):
     91        (WebCore::toJS): Updated to use our new interface for customizing wrapper
     92        lifetime management through function overloading without using
     93        MarkStack::deprecatedAppend or special-case code for nodes.
     94       
     95        * bindings/js/JSSVGPathSegCustom.cpp:
     96        (WebCore::toJS):
     97        * bindings/js/JSStyleSheetCustom.cpp:
     98        (WebCore::toJS): Updated for renames mentioned above.
     99
     100        * bindings/scripts/CodeGeneratorJS.pm: Fixed up newlines. Updated for
     101        renames mentioned above.
     102
     103        * dom/NamedNodeMap.idl: NamedNodeMap needs a custom toJS function now
     104        because it needs to provide a custom WeakHandleOwner at wrapper creation time.
     105
    11062011-04-18  Jessie Berlin  <jberlin@apple.com>
    2107
  • trunk/Source/WebCore/WebCore.exp.in

    r84120 r84194  
    598598__ZN7WebCore25addLanguageChangeObserverEPvPFvS0_E
    599599__ZN7WebCore25contextMenuItemTagOutlineEv
    600 __ZN7WebCore25getCachedDOMObjectWrapperEPNS_15DOMWrapperWorldEPv
    601600__ZN7WebCore26CSSMutableStyleDeclarationC1Ev
    602601__ZN7WebCore26UserTypingGestureIndicator27processingUserTypingGestureEv
  • trunk/Source/WebCore/bindings/js/DOMWrapperWorld.cpp

    r84105 r84194  
    2222#include "DOMWrapperWorld.h"
    2323
    24 #include "HTMLAudioElement.h"
    25 #include "HTMLCanvasElement.h"
    26 #include "HTMLFrameElementBase.h"
    27 #include "HTMLImageElement.h"
    28 #include "HTMLLinkElement.h"
    29 #include "HTMLNames.h"
    30 #include "HTMLScriptElement.h"
    31 #include "HTMLStyleElement.h"
    3224#include "JSDOMWindow.h"
    33 #include "JSNode.h"
    34 #include "ProcessingInstruction.h"
    35 #include "ScriptController.h"
    36 #include "StyleSheet.h"
    37 #include "StyledElement.h"
    3825#include "WebCoreJSClientData.h"
    39 #include <heap/Weak.h>
    4026
    4127using namespace JSC;
     
    4329namespace WebCore {
    4430
    45 using namespace HTMLNames;
    46 
    47 static bool isObservable(JSNode* jsNode, Node* node, DOMWrapperWorld* world)
     31void JSDOMWrapperOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
    4832{
    49     // Certain conditions implicitly make existence of a JS DOM node wrapper observable
    50     // through the DOM, even if no explicit reference to it remains.
    51    
    52     // The DOM doesn't know how to keep a tree of nodes alive without the root
    53     // being explicitly referenced. So, we artificially treat the root of
    54     // every tree as observable.
    55     // FIXME: Resolve this lifetime issue in the DOM, and remove this inefficiency.
    56     if (!node->parentNode())
    57         return true;
    58 
    59     // If a node is in the document, and its wrapper has custom properties,
    60     // the wrapper is observable because future access to the node through the
    61     // DOM must reflect those properties.
    62     if (jsNode->hasCustomProperties())
    63         return true;
    64 
    65     // If a node is in the document, and has event listeners, its wrapper is
    66     // observable because its wrapper is responsible for marking those event listeners.
    67     if (node->hasEventListeners())
    68         return true;
    69 
    70     // If a node owns another object with a wrapper with custom properties,
    71     // the wrapper must be treated as observable, because future access to
    72     // those objects through the DOM must reflect those properties.
    73     // FIXME: It would be better if this logic could be in the node next to
    74     // the custom markChildren functions rather than here.
    75     // Note that for some compound objects like stylesheets and CSSStyleDeclarations,
    76     // we don't descend to check children for custom properties, and just conservatively
    77     // keep the node wrappers protecting them alive.
    78     if (node->isElementNode()) {
    79         if (NamedNodeMap* attributes = static_cast<Element*>(node)->attributeMap()) {
    80             if (JSDOMWrapper* wrapper = world->m_wrappers.get(attributes).get()) {
    81                 // FIXME: This check seems insufficient, because NamedNodeMap items can have custom properties themselves.
    82                 // Maybe it would be OK to just keep the wrapper alive, as it is done for CSSOM objects below.
    83                 if (wrapper->hasCustomProperties())
    84                     return true;
    85             }
    86         }
    87         if (node->isStyledElement()) {
    88             if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) {
    89                 if (world->m_wrappers.get(style))
    90                     return true;
    91             }
    92         }
    93         if (static_cast<Element*>(node)->hasTagName(canvasTag)) {
    94             if (CanvasRenderingContext* context = static_cast<HTMLCanvasElement*>(node)->renderingContext()) {
    95                 if (JSDOMWrapper* wrapper = world->m_wrappers.get(context).get()) {
    96                     if (wrapper->hasCustomProperties())
    97                         return true;
    98                 }
    99             }
    100         } else if (static_cast<Element*>(node)->hasTagName(linkTag)) {
    101             if (StyleSheet* sheet = static_cast<HTMLLinkElement*>(node)->sheet()) {
    102                 if (world->m_wrappers.get(sheet))
    103                     return true;
    104             }
    105         } else if (static_cast<Element*>(node)->hasTagName(styleTag)) {
    106             if (StyleSheet* sheet = static_cast<HTMLStyleElement*>(node)->sheet()) {
    107                 if (world->m_wrappers.get(sheet))
    108                     return true;
    109             }
    110         }
    111     } else if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
    112         if (StyleSheet* sheet = static_cast<ProcessingInstruction*>(node)->sheet()) {
    113             if (world->m_wrappers.get(sheet))
    114                 return true;
    115         }
    116     }
    117 
    118     return false;
    119 }
    120 
    121 static inline bool isReachableFromDOM(JSNode* jsNode, Node* node, DOMWrapperWorld* world, MarkStack& markStack)
    122 {
    123     if (!node->inDocument()) {
    124         // If a wrapper is the last reference to an image or script element
    125         // that is loading but not in the document, the wrapper is observable
    126         // because it is the only thing keeping the image element alive, and if
    127         // the image element is destroyed, its load event will not fire.
    128         // FIXME: The DOM should manage this issue without the help of JavaScript wrappers.
    129         if (node->hasTagName(imgTag) && !static_cast<HTMLImageElement*>(node)->haveFiredLoadEvent())
    130             return true;
    131         if (node->hasTagName(scriptTag) && !static_cast<HTMLScriptElement*>(node)->haveFiredLoadEvent())
    132             return true;
    133     #if ENABLE(VIDEO)
    134         if (node->hasTagName(audioTag) && !static_cast<HTMLAudioElement*>(node)->paused())
    135             return true;
    136     #endif
    137 
    138         // If a node is firing event listeners, its wrapper is observable because
    139         // its wrapper is responsible for marking those event listeners.
    140         if (node->isFiringEventListeners())
    141             return true;
    142     }
    143 
    144     return isObservable(jsNode, node, world) && markStack.containsOpaqueRoot(root(node));
     33    JSDOMWrapper* wrapper = static_cast<JSDOMWrapper*>(handle.get().asCell());
     34    void* domObject = context;
     35    uncacheWrapper(m_world, domObject, wrapper);
    14536}
    14637
     
    14839    : m_globalData(globalData)
    14940    , m_isNormal(isNormal)
    150     , m_jsNodeHandleOwner(this)
    151     , m_domObjectHandleOwner(this)
     41    , m_defaultWrapperOwner(this)
    15242{
    15343    JSGlobalData::ClientData* clientData = m_globalData->clientData;
     
    18373}
    18474
    185 bool JSNodeHandleOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, JSC::MarkStack& markStack)
    186 {
    187     JSNode* jsNode = static_cast<JSNode*>(handle.get().asCell());
    188     return isReachableFromDOM(jsNode, jsNode->impl(), m_world, markStack);
    189 }
    190 
    191 void JSNodeHandleOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
    192 {
    193     JSNode* jsNode = static_cast<JSNode*>(handle.get().asCell());
    194     uncacheDOMNodeWrapper(m_world, static_cast<Node*>(context), jsNode);
    195 }
    196 
    197 bool DOMObjectHandleOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void*, JSC::MarkStack&)
    198 {
    199     return false;
    200 }
    201 
    202 void DOMObjectHandleOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
    203 {
    204     JSDOMWrapper* domObject = static_cast<JSDOMWrapper*>(handle.get().asCell());
    205     uncacheDOMObjectWrapper(m_world, context, domObject);
    206 }
    207 
    20875} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/DOMWrapperWorld.h

    r84105 r84194  
    2424
    2525#include "JSDOMGlobalObject.h"
     26#include <heap/Weak.h>
    2627#include <runtime/WeakGCMap.h>
    2728#include <wtf/Forward.h>
     
    3536typedef JSC::WeakGCMap<StringImpl*, JSC::JSString> JSStringCache;
    3637
    37 class JSNodeHandleOwner : public JSC::WeakHandleOwner {
     38class JSDOMWrapperOwner : public JSC::WeakHandleOwner {
    3839public:
    39     JSNodeHandleOwner(DOMWrapperWorld*);
    40     virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void*, JSC::MarkStack&);
    41     virtual void finalize(JSC::Handle<JSC::Unknown>, void*);
     40    JSDOMWrapperOwner(DOMWrapperWorld*);
     41    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
    4242
    4343private:
     
    4545};
    4646
    47 inline JSNodeHandleOwner::JSNodeHandleOwner(DOMWrapperWorld* world)
    48     : m_world(world)
    49 {
    50 }
    51 
    52 class DOMObjectHandleOwner : public JSC::WeakHandleOwner {
    53 public:
    54     DOMObjectHandleOwner(DOMWrapperWorld*);
    55     virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void*, JSC::MarkStack&);
    56     virtual void finalize(JSC::Handle<JSC::Unknown>, void*);
    57 
    58 private:
    59     DOMWrapperWorld* m_world;
    60 };
    61 
    62 inline DOMObjectHandleOwner::DOMObjectHandleOwner(DOMWrapperWorld* world)
     47inline JSDOMWrapperOwner::JSDOMWrapperOwner(DOMWrapperWorld* world)
    6348    : m_world(world)
    6449{
     
    8671
    8772    JSC::JSGlobalData* globalData() const { return m_globalData; }
    88     JSNodeHandleOwner* jsNodeHandleOwner() { return &m_jsNodeHandleOwner; }
    89     DOMObjectHandleOwner* domObjectHandleOwner() { return &m_domObjectHandleOwner; }
     73    JSDOMWrapperOwner* defaultWrapperOwner() { return &m_defaultWrapperOwner; }
    9074
    9175protected:
     
    9680    HashSet<ScriptController*> m_scriptControllersWithWindowShells;
    9781    bool m_isNormal;
    98     JSNodeHandleOwner m_jsNodeHandleOwner;
    99     DOMObjectHandleOwner m_domObjectHandleOwner;
     82    JSDOMWrapperOwner m_defaultWrapperOwner;
    10083};
    10184
  • trunk/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h

    r84105 r84194  
    164164        return JSC::jsNull();
    165165
    166     if (JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), object))
     166    if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), object))
    167167        return wrapper;
    168168
    169169    exec->heap()->reportExtraMemoryCost(object->byteLength());
    170     return createDOMObjectWrapper<JSType>(exec, globalObject, object);
     170    return createWrapper<JSType>(exec, globalObject, object);
    171171}
    172172
  • trunk/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp

    r84105 r84194  
    6464        return jsNull();
    6565
    66     JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), rule);
     66    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), rule);
    6767    if (wrapper)
    6868        return wrapper;
  • trunk/Source/WebCore/bindings/js/JSCSSValueCustom.cpp

    r84105 r84194  
    5050        return jsNull();
    5151
    52     JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), value);
     52    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), value);
    5353
    5454    if (wrapper)
  • trunk/Source/WebCore/bindings/js/JSCanvasRenderingContextCustom.cpp

    r76600 r84194  
    4545#if ENABLE(WEBGL)
    4646    if (object->is3d())
    47         return getDOMObjectWrapper<JSWebGLRenderingContext>(exec, globalObject, static_cast<WebGLRenderingContext*>(object));
     47        return wrap<JSWebGLRenderingContext>(exec, globalObject, static_cast<WebGLRenderingContext*>(object));
    4848#endif
    4949    ASSERT(object->is2d());
    50     return getDOMObjectWrapper<JSCanvasRenderingContext2D>(exec, globalObject, static_cast<CanvasRenderingContext2D*>(object));
     50    return wrap<JSCanvasRenderingContext2D>(exec, globalObject, static_cast<CanvasRenderingContext2D*>(object));
    5151}
    5252
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r84105 r84194  
    4545#include "JSExceptionBase.h"
    4646#include "JSMainThreadExecState.h"
    47 #include "JSNode.h"
    4847#include "JSRangeException.h"
    4948#include "JSXMLHttpRequestException.h"
     
    136135}
    137136
    138 JSDOMWrapper* getCachedDOMObjectWrapper(DOMWrapperWorld* world, void* objectHandle)
    139 {
    140     return world->m_wrappers.get(objectHandle).get();
    141 }
    142 
    143 void cacheDOMObjectWrapper(DOMWrapperWorld* world, void* objectHandle, JSDOMWrapper* wrapper)
    144 {
    145     world->m_wrappers.set(objectHandle, Weak<JSDOMWrapper>(*world->globalData(), wrapper, world->domObjectHandleOwner(), objectHandle));
    146 }
    147 
    148 void uncacheDOMObjectWrapper(DOMWrapperWorld* world, void* objectHandle, JSDOMWrapper* wrapper)
    149 {
    150     ASSERT_UNUSED(wrapper, world->m_wrappers.find(objectHandle)->second.get() == wrapper);
    151     world->m_wrappers.remove(objectHandle);
    152 }
    153 
    154137void markActiveObjectsForContext(MarkStack& markStack, JSGlobalData& globalData, ScriptExecutionContext* scriptExecutionContext)
    155138{
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r84105 r84194  
    2727#include "DOMWrapperWorld.h"
    2828#include "Document.h"
     29#include <heap/Weak.h>
    2930#include <runtime/Completion.h>
    3031#include <runtime/Lookup.h>
     
    112113        }
    113114    };
    114 
    115     JSDOMWrapper* getCachedDOMObjectWrapper(DOMWrapperWorld*, void* objectHandle);
    116     void cacheDOMObjectWrapper(DOMWrapperWorld*, void* objectHandle, JSDOMWrapper* wrapper);
    117     void uncacheDOMObjectWrapper(DOMWrapperWorld*, void* objectHandle, JSDOMWrapper* wrapper);
    118 
    119     JSNode* getCachedDOMNodeWrapper(DOMWrapperWorld*, Node*);
    120     void cacheDOMNodeWrapper(DOMWrapperWorld*, Node*, JSNode* wrapper);
    121     void uncacheDOMNodeWrapper(DOMWrapperWorld*, Node*, JSNode* wrapper);
    122115   
    123116    void markActiveObjectsForContext(JSC::MarkStack&, JSC::JSGlobalData&, ScriptExecutionContext*);
     
    141134        return cacheDOMStructure(globalObject, WrapperClass::createStructure(exec->globalData(), WrapperClass::createPrototype(exec, globalObject)), &WrapperClass::s_info);
    142135    }
     136
    143137    template<class WrapperClass> inline JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState* exec)
    144138    {
     
    146140        return getDOMStructure<WrapperClass>(exec, deprecatedGlobalObjectForPrototype(exec));
    147141    }
     142
    148143    template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject)
    149144    {
    150145        return static_cast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec, static_cast<JSDOMGlobalObject*>(globalObject))->storedPrototype()));
    151146    }
    152     #define CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, className, object) createDOMObjectWrapper<JS##className>(exec, globalObject, static_cast<className*>(object))
    153     template<class WrapperClass, class DOMClass> inline JSDOMWrapper* createDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object)
    154     {
    155         ASSERT(object);
    156         ASSERT(!getCachedDOMObjectWrapper(currentWorld(exec), object));
    157         // FIXME: new (exec) could use a different globalData than the globalData this wrapper is cached on.
    158         WrapperClass* wrapper = new (exec) WrapperClass(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, object);
    159         cacheDOMObjectWrapper(currentWorld(exec), object, wrapper);
    160         return wrapper;
    161     }
    162     template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object)
    163     {
    164         if (!object)
    165             return JSC::jsNull();
    166         if (JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), object))
     147
     148    // Overload these functions to provide a fast path for wrapper access.
     149    inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld*, void*) { return 0; }
     150    inline bool setInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*) { return false; }
     151    inline bool clearInlineCachedWrapper(DOMWrapperWorld*, void*, JSDOMWrapper*) { return false; }
     152
     153    // Overload these functions to provide a custom WeakHandleOwner.
     154    inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld* world, void*) { return world->defaultWrapperOwner(); }
     155    inline void* wrapperContext(DOMWrapperWorld*, void* domObject) { return domObject; }
     156
     157    template <typename DOMClass> inline JSDOMWrapper* getCachedWrapper(DOMWrapperWorld* world, DOMClass* domObject)
     158    {
     159        if (JSDOMWrapper* wrapper = getInlineCachedWrapper(world, domObject))
    167160            return wrapper;
    168         return createDOMObjectWrapper<WrapperClass>(exec, globalObject, object);
    169     }
    170 
    171     #define CREATE_DOM_NODE_WRAPPER(exec, globalObject, className, object) createDOMNodeWrapper<JS##className>(exec, globalObject, static_cast<className*>(object))
    172     template<class WrapperClass, class DOMClass> inline JSNode* createDOMNodeWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node)
     161        return world->m_wrappers.get(domObject).get();
     162    }
     163
     164    template <typename DOMClass> inline void cacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, JSDOMWrapper* wrapper)
     165    {
     166        if (setInlineCachedWrapper(world, domObject, wrapper))
     167            return;
     168        ASSERT(!world->m_wrappers.contains(domObject));
     169        world->m_wrappers.set(domObject, JSC::Weak<JSDOMWrapper>(*world->globalData(), wrapper, wrapperOwner(world, domObject), wrapperContext(world, domObject)));
     170    }
     171
     172    template <typename DOMClass> inline void uncacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, JSDOMWrapper* wrapper)
     173    {
     174        if (clearInlineCachedWrapper(world, domObject, wrapper))
     175            return;
     176        ASSERT(world->m_wrappers.find(domObject)->second.get() == wrapper);
     177        world->m_wrappers.remove(domObject);
     178    }
     179   
     180    #define CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, className, object) createWrapper<JS##className>(exec, globalObject, static_cast<className*>(object))
     181    #define CREATE_DOM_NODE_WRAPPER(exec, globalObject, className, object) static_cast<JSNode*>(createWrapper<JS##className>(exec, globalObject, static_cast<className*>(object)))
     182    template<class WrapperClass, class DOMClass> inline JSDOMWrapper* createWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node)
    173183    {
    174184        ASSERT(node);
    175         ASSERT(!getCachedDOMNodeWrapper(currentWorld(exec), node));
     185        ASSERT(!getCachedWrapper(currentWorld(exec), node));
    176186        WrapperClass* wrapper = new (exec) WrapperClass(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, node);
    177187        // FIXME: The entire function can be removed, once we fix caching.
    178188        // This function is a one-off hack to make Nodes cache in the right global object.
    179         cacheDOMNodeWrapper(currentWorld(exec), node, wrapper);
     189        cacheWrapper(currentWorld(exec), node, wrapper);
    180190        return wrapper;
    181191    }
    182     template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMNodeWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node)
    183     {
    184         if (!node)
     192
     193    template<class WrapperClass, class DOMClass> inline JSC::JSValue wrap(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* domObject)
     194    {
     195        if (!domObject)
    185196            return JSC::jsNull();
    186         if (JSC::JSCell* wrapper = getCachedDOMNodeWrapper(currentWorld(exec), node))
     197        if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), domObject))
    187198            return wrapper;
    188         return createDOMNodeWrapper<WrapperClass>(exec, globalObject, node);
     199        return createWrapper<WrapperClass>(exec, globalObject, domObject);
    189200    }
    190201
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r84105 r84194  
    442442{
    443443    History* history = impl()->history();
    444     if (JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), history))
     444    if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), history))
    445445        return wrapper;
    446446
    447447    JSDOMWindow* window = const_cast<JSDOMWindow*>(this);
    448448    JSHistory* jsHistory = new (exec) JSHistory(getDOMStructure<JSHistory>(exec, window), window, history);
    449     cacheDOMObjectWrapper(currentWorld(exec), history, jsHistory);
     449    cacheWrapper(currentWorld(exec), history, jsHistory);
    450450    return jsHistory;
    451451}
     
    454454{
    455455    Location* location = impl()->location();
    456     if (JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), location))
     456    if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), location))
    457457        return wrapper;
    458458
    459459    JSDOMWindow* window = const_cast<JSDOMWindow*>(this);
    460460    JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, window), window, location);
    461     cacheDOMObjectWrapper(currentWorld(exec), location, jsLocation);
     461    cacheWrapper(currentWorld(exec), location, jsLocation);
    462462    return jsLocation;
    463463}
  • trunk/Source/WebCore/bindings/js/JSDataViewCustom.cpp

    r78407 r84194  
    4545JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, DataView* object)
    4646{
    47     return getDOMObjectWrapper<JSDataView>(exec, globalObject, object);
     47    return wrap<JSDataView>(exec, globalObject, object);
    4848}
    4949
  • trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r84105 r84194  
    6969
    7070    Location* location = frame->domWindow()->location();
    71     if (JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), location))
     71    if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), location))
    7272        return wrapper;
    7373
    7474    JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, globalObject()), globalObject(), location);
    75     cacheDOMObjectWrapper(currentWorld(exec), location, jsLocation);
     75    cacheWrapper(currentWorld(exec), location, jsLocation);
    7676    return jsLocation;
    7777}
     
    101101        return jsNull();
    102102
    103     JSDOMWrapper* wrapper = getCachedDOMNodeWrapper(currentWorld(exec), document);
     103    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), document);
    104104    if (wrapper)
    105105        return wrapper;
  • trunk/Source/WebCore/bindings/js/JSElementCustom.cpp

    r84029 r84194  
    7272        return jsNull();
    7373
    74     ASSERT(!getCachedDOMNodeWrapper(currentWorld(exec), element));
     74    ASSERT(!getCachedWrapper(currentWorld(exec), element));
    7575
    7676    JSNode* wrapper;       
  • trunk/Source/WebCore/bindings/js/JSEventCustom.cpp

    r84105 r84194  
    122122        return jsNull();
    123123
    124     JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), event);
     124    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), event);
    125125    if (wrapper)
    126126        return wrapper;
  • trunk/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp

    r84105 r84194  
    135135        return jsNull();
    136136
    137     JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), collection);
     137    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), collection);
    138138
    139139    if (wrapper)
  • trunk/Source/WebCore/bindings/js/JSImageDataCustom.cpp

    r84105 r84194  
    4242        return jsNull();
    4343   
    44     JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), imageData);
     44    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), imageData);
    4545    if (wrapper)
    4646        return wrapper;
  • trunk/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp

    r83938 r84194  
    3636namespace WebCore {
    3737
     38class JSNamedNodeMapOwner : public JSC::WeakHandleOwner {
     39    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     40    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     41};
     42
     43bool JSNamedNodeMapOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
     44{
     45    JSNamedNodeMap* jsNamedNodeMap = static_cast<JSNamedNodeMap*>(handle.get().asCell());
     46    if (!jsNamedNodeMap->hasCustomProperties())
     47        return false;
     48    Element* element = jsNamedNodeMap->impl()->element();
     49    if (!element)
     50        return false;
     51    return markStack.containsOpaqueRoot(root(element));
     52}
     53
     54void JSNamedNodeMapOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     55{
     56    JSNamedNodeMap* jsNamedNodeMap = static_cast<JSNamedNodeMap*>(handle.get().asCell());
     57    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     58    uncacheWrapper(world, jsNamedNodeMap->impl(), jsNamedNodeMap);
     59}
     60
     61inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, NamedNodeMap*)
     62{
     63    DEFINE_STATIC_LOCAL(JSNamedNodeMapOwner, jsNamedNodeMapOwner, ());
     64    return &jsNamedNodeMapOwner;
     65}
     66
     67inline void* wrapperContext(DOMWrapperWorld* world, NamedNodeMap*)
     68{
     69    return world;
     70}
     71
    3872bool JSNamedNodeMap::canGetItemsForName(ExecState*, NamedNodeMap* impl, const Identifier& propertyName)
    3973{
     
    5185    Base::markChildren(markStack);
    5286
     87    // We need to keep the wrapper for our underlying NamedNodeMap's element
     88    // alive because NamedNodeMap and Attr rely on the element for data, and
     89    // don't know how to keep it alive correctly.
     90    // FIXME: Fix this lifetime issue in the DOM, and remove this.
    5391    Element* element = impl()->element();
    5492    if (!element)
     
    5795}
    5896
     97JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, NamedNodeMap* impl)
     98{
     99    return wrap<JSNamedNodeMap>(exec, globalObject, impl);
     100}
     101
    59102} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSNodeCustom.cpp

    r84029 r84194  
    3636#include "EntityReference.h"
    3737#include "ExceptionCode.h"
     38#include "HTMLAudioElement.h"
     39#include "HTMLCanvasElement.h"
    3840#include "HTMLElement.h"
     41#include "HTMLFrameElementBase.h"
     42#include "HTMLImageElement.h"
     43#include "HTMLLinkElement.h"
     44#include "HTMLNames.h"
     45#include "HTMLScriptElement.h"
     46#include "HTMLStyleElement.h"
    3947#include "JSAttr.h"
    4048#include "JSCDATASection.h"
     
    5664#include "ProcessingInstruction.h"
    5765#include "RegisteredEventListener.h"
     66#include "StyleSheet.h"
     67#include "StyledElement.h"
    5868#include "Text.h"
    5969#include <wtf/PassRefPtr.h>
     
    6878
    6979namespace WebCore {
     80
     81using namespace HTMLNames;
     82
     83static bool isObservable(JSNode* jsNode, Node* node, DOMWrapperWorld* world)
     84{
     85    // Certain conditions implicitly make existence of a JS DOM node wrapper observable
     86    // through the DOM, even if no explicit reference to it remains.
     87   
     88    // The DOM doesn't know how to keep a tree of nodes alive without the root
     89    // being explicitly referenced. So, we artificially treat the root of
     90    // every tree as observable.
     91    // FIXME: Resolve this lifetime issue in the DOM, and remove this inefficiency.
     92    if (!node->parentNode())
     93        return true;
     94
     95    // If a node is in the document, and its wrapper has custom properties,
     96    // the wrapper is observable because future access to the node through the
     97    // DOM must reflect those properties.
     98    if (jsNode->hasCustomProperties())
     99        return true;
     100
     101    // If a node is in the document, and has event listeners, its wrapper is
     102    // observable because its wrapper is responsible for marking those event listeners.
     103    if (node->hasEventListeners())
     104        return true;
     105
     106    // If a node owns another object with a wrapper with custom properties,
     107    // the wrapper must be treated as observable, because future access to
     108    // those objects through the DOM must reflect those properties.
     109    // FIXME: It would be better if this logic could be in the node next to
     110    // the custom markChildren functions rather than here.
     111    // Note that for some compound objects like stylesheets and CSSStyleDeclarations,
     112    // we don't descend to check children for custom properties, and just conservatively
     113    // keep the node wrappers protecting them alive.
     114    if (node->isElementNode()) {
     115        if (node->isStyledElement()) {
     116            if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) {
     117                if (world->m_wrappers.get(style))
     118                    return true;
     119            }
     120        }
     121        if (static_cast<Element*>(node)->hasTagName(canvasTag)) {
     122            if (CanvasRenderingContext* context = static_cast<HTMLCanvasElement*>(node)->renderingContext()) {
     123                if (JSDOMWrapper* wrapper = world->m_wrappers.get(context).get()) {
     124                    if (wrapper->hasCustomProperties())
     125                        return true;
     126                }
     127            }
     128        } else if (static_cast<Element*>(node)->hasTagName(linkTag)) {
     129            if (StyleSheet* sheet = static_cast<HTMLLinkElement*>(node)->sheet()) {
     130                if (world->m_wrappers.get(sheet))
     131                    return true;
     132            }
     133        } else if (static_cast<Element*>(node)->hasTagName(styleTag)) {
     134            if (StyleSheet* sheet = static_cast<HTMLStyleElement*>(node)->sheet()) {
     135                if (world->m_wrappers.get(sheet))
     136                    return true;
     137            }
     138        }
     139    } else if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
     140        if (StyleSheet* sheet = static_cast<ProcessingInstruction*>(node)->sheet()) {
     141            if (world->m_wrappers.get(sheet))
     142                return true;
     143        }
     144    }
     145
     146    return false;
     147}
     148
     149static inline bool isReachableFromDOM(JSNode* jsNode, Node* node, DOMWrapperWorld* world, MarkStack& markStack)
     150{
     151    if (!node->inDocument()) {
     152        // If a wrapper is the last reference to an image or script element
     153        // that is loading but not in the document, the wrapper is observable
     154        // because it is the only thing keeping the image element alive, and if
     155        // the image element is destroyed, its load event will not fire.
     156        // FIXME: The DOM should manage this issue without the help of JavaScript wrappers.
     157        if (node->hasTagName(imgTag) && !static_cast<HTMLImageElement*>(node)->haveFiredLoadEvent())
     158            return true;
     159        if (node->hasTagName(scriptTag) && !static_cast<HTMLScriptElement*>(node)->haveFiredLoadEvent())
     160            return true;
     161    #if ENABLE(VIDEO)
     162        if (node->hasTagName(audioTag) && !static_cast<HTMLAudioElement*>(node)->paused())
     163            return true;
     164    #endif
     165
     166        // If a node is firing event listeners, its wrapper is observable because
     167        // its wrapper is responsible for marking those event listeners.
     168        if (node->isFiringEventListeners())
     169            return true;
     170    }
     171
     172    return isObservable(jsNode, node, world) && markStack.containsOpaqueRoot(root(node));
     173}
     174
     175bool JSNodeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, MarkStack& markStack)
     176{
     177    JSNode* jsNode = static_cast<JSNode*>(handle.get().asCell());
     178    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     179    return isReachableFromDOM(jsNode, jsNode->impl(), world, markStack);
     180}
     181
     182void JSNodeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     183{
     184    JSNode* jsNode = static_cast<JSNode*>(handle.get().asCell());
     185    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     186    uncacheWrapper(world, jsNode->impl(), jsNode);
     187}
    70188
    71189JSValue JSNode::insertBefore(ExecState* exec)
     
    131249{
    132250    ASSERT(node);
    133     ASSERT(!getCachedDOMNodeWrapper(currentWorld(exec), node));
     251    ASSERT(!getCachedWrapper(currentWorld(exec), node));
    134252   
    135253    JSNode* wrapper;   
  • trunk/Source/WebCore/bindings/js/JSNodeCustom.h

    r84049 r84194  
    3232namespace WebCore {
    3333
    34 inline JSNode* getCachedDOMNodeWrapper(DOMWrapperWorld* world, Node* node)
     34class JSNodeOwner : public JSC::WeakHandleOwner {
     35    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     36    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     37};
     38
     39inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, Node*)
    3540{
    36     if (world->isNormal())
    37         return static_cast<JSNode*>(node->wrapper());
    38     return static_cast<JSNode*>(getCachedDOMObjectWrapper(world, node));
     41    DEFINE_STATIC_LOCAL(JSNodeOwner, jsNodeOwner, ());
     42    return &jsNodeOwner;
    3943}
    4044
    41 inline void cacheDOMNodeWrapper(DOMWrapperWorld* world, Node* node, JSNode* wrapper)
     45inline void* wrapperContext(DOMWrapperWorld* world, Node*)
    4246{
    43     ASSERT(wrapper);
    44     if (world->isNormal()) {
    45         node->setWrapper(*world->globalData(), wrapper, world->jsNodeHandleOwner(), node);
    46         return;
    47     }
    48     cacheDOMObjectWrapper(world, node, wrapper);
     47    return world;
    4948}
    5049
    51 inline void uncacheDOMNodeWrapper(DOMWrapperWorld* world, Node* node, JSNode* jsNode)
     50inline JSDOMWrapper* getInlineCachedWrapper(DOMWrapperWorld* world, Node* node)
    5251{
    53     if (world->isNormal()) {
    54         node->clearWrapper();
    55         return;
    56     }
    57     uncacheDOMObjectWrapper(world, node, jsNode);
     52    if (!world->isNormal())
     53        return 0;
     54    return node->wrapper();
     55}
     56
     57inline bool setInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrapper* wrapper)
     58{
     59    if (!world->isNormal())
     60        return false;
     61    ASSERT(!node->wrapper());
     62    node->setWrapper(*world->globalData(), wrapper, wrapperOwner(world, node), wrapperContext(world, node));
     63    return true;
     64}
     65
     66inline bool clearInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrapper* wrapper)
     67{
     68    if (!world->isNormal())
     69        return false;
     70    ASSERT_UNUSED(wrapper, node->wrapper() == wrapper);
     71    node->clearWrapper();
     72    return true;
    5873}
    5974
     
    6580        return JSC::jsNull();
    6681
    67     JSNode* wrapper = getCachedDOMNodeWrapper(currentWorld(exec), node);
     82    JSNode* wrapper = static_cast<JSNode*>(getCachedWrapper(currentWorld(exec), node));
    6883    if (wrapper)
    6984        return wrapper;
  • trunk/Source/WebCore/bindings/js/JSSVGPathSegCustom.cpp

    r84105 r84194  
    6464        return jsNull();
    6565
    66     if (JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), object))
     66    if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), object))
    6767        return wrapper;
    6868
  • trunk/Source/WebCore/bindings/js/JSStyleSheetCustom.cpp

    r84105 r84194  
    4141        return jsNull();
    4242
    43     JSDOMWrapper* wrapper = getCachedDOMObjectWrapper(currentWorld(exec), styleSheet);
     43    JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), styleSheet);
    4444    if (wrapper)
    4545        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r84105 r84194  
    13051305        push(@implContent, "{\n");
    13061306        push(@implContent, "    return getHashTableForGlobalData(exec->globalData(), &${className}PrototypeTable);\n");
    1307         push(@implContent, "}\n");
     1307        push(@implContent, "}\n\n");
    13081308        push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", &JSC::JSObjectWithGlobalObject::s_info, 0, get${className}PrototypeTable };\n\n");
    13091309    } else {
     
    13801380        push(@implContent, "{\n");
    13811381        push(@implContent, "    return getHashTableForGlobalData(exec->globalData(), &${className}Table);\n");
    1382         push(@implContent, "}\n");
     1382        push(@implContent, "}\n\n");
    13831383    }
    13841384
     
    15911591                }
    15921592
    1593                 push(@implContent, "}\n");
     1593                push(@implContent, "}\n\n");
    15941594
    15951595                push(@implContent, "#endif\n") if $attributeConditionalString;
     
    16111611
    16121612                push(@implContent, "    return ${className}::getConstructor(exec, domObject->globalObject());\n");
    1613                 push(@implContent, "}\n");
    1614                 push(@implContent, "\n");
     1613                push(@implContent, "}\n\n");
    16151614            }
    16161615        }
     
    17701769                        }
    17711770                       
    1772                         push(@implContent, "}\n");
     1771                        push(@implContent, "}\n\n");
    17731772
    17741773                        push(@implContent, "#endif\n") if $attributeConditionalString;
     
    18001799                    push(@implContent, "    static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n");
    18011800                }
    1802                 push(@implContent, "}\n");
    1803                 push(@implContent, "\n");
     1801                push(@implContent, "}\n\n");
    18041802            }       
    18051803        }
     
    20962094            push(@implContent, "    return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(index));\n");
    20972095        }
    2098         push(@implContent, "}\n");
     2096        push(@implContent, "}\n\n");
    20992097        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
    21002098            $implIncludes{"JSNode.h"} = 1;
     
    21072105        push(@implContent, "{\n");
    21082106        push(@implContent, "    return jsNumber(static_cast<$implClassName*>(impl())->item(index));\n");
    2109         push(@implContent, "}\n");
     2107        push(@implContent, "}\n\n");
    21102108        if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
    21112109            $implIncludes{"JSNode.h"} = 1;
     
    21162114    if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateToJS"}) and !$dataNode->extendedAttributes->{"CustomToJS"}) {
    21172115        if ($svgPropertyType) {
    2118             push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object)\n");
     2116            push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* impl)\n");
    21192117        } else {
    2120             push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object)\n");
     2118            push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* impl)\n");
    21212119        }
    21222120        push(@implContent, "{\n");
    21232121        if ($svgPropertyType) {
    2124             push(@implContent, "    return getDOMObjectWrapper<$className, $implType>(exec, globalObject, object);\n");
     2122            push(@implContent, "    return wrap<$className, $implType>(exec, globalObject, impl);\n");
    21252123        } else {
    2126             push(@implContent, "    return getDOMObjectWrapper<$className>(exec, globalObject, object);\n");
    2127         }
    2128         push(@implContent, "}\n");
     2124            push(@implContent, "    return wrap<$className>(exec, globalObject, impl);\n");
     2125        }
     2126        push(@implContent, "}\n\n");
    21292127    }
    21302128
  • trunk/Source/WebCore/dom/NamedNodeMap.idl

    r60022 r84194  
    2222
    2323    interface [
     24        CustomToJS,
    2425        CustomMarkFunction,
    2526        HasIndexGetter,
Note: See TracChangeset for help on using the changeset viewer.