Changeset 84309 in webkit


Ignore:
Timestamp:
Apr 19, 2011 4:32:39 PM (13 years ago)
Author:
ggaren@apple.com
Message:

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

Reviewed by Oliver Hunt.

Removed a use of markDOMObjectWrapper: NodeLists
https://bugs.webkit.org/show_bug.cgi?id=58939

  • bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::markChildren): No need to mark node lists, because now they use the opaque roots system to decide their lifetimes.
  • bindings/js/JSNamedNodeMapCustom.cpp: Removed stray newline.
  • bindings/js/JSNodeListCustom.cpp: (WebCore::JSNodeListOwner::isReachableFromOpaqueRoots): (WebCore::JSNodeListOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::toJS): Use the opaque roots system to avoid relying on markDOMObjectWrapper.
  • dom/DynamicNodeList.cpp: (WebCore::DynamicNodeList::isDynamicNodeList):
  • dom/DynamicNodeList.h: (WebCore::DynamicNodeList::rootNode): Added the ability to get the node backing a NodeList, for use in the opaque roots system.
  • dom/Node.cpp:
  • dom/Node.h:
  • dom/NodeList.h: (WebCore::NodeList::isDynamicNodeList): Ditto. Removed cruft related to the old way of marking NodeLists.
  • dom/NodeList.idl: We need a custom toJS so we can specify a custom WeakHandleOwner at construction time.
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84307 r84309  
     12011-04-19  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Removed a use of markDOMObjectWrapper: NodeLists
     6        https://bugs.webkit.org/show_bug.cgi?id=58939
     7
     8        * bindings/js/JSDocumentCustom.cpp:
     9        (WebCore::JSDocument::markChildren): No need to mark node lists, because
     10        now they use the opaque roots system to decide their lifetimes.
     11
     12        * bindings/js/JSNamedNodeMapCustom.cpp: Removed stray newline.
     13
     14        * bindings/js/JSNodeListCustom.cpp:
     15        (WebCore::JSNodeListOwner::isReachableFromOpaqueRoots):
     16        (WebCore::JSNodeListOwner::finalize):
     17        (WebCore::wrapperOwner):
     18        (WebCore::wrapperContext):
     19        (WebCore::toJS): Use the opaque roots system to avoid relying on
     20        markDOMObjectWrapper.
     21
     22        * dom/DynamicNodeList.cpp:
     23        (WebCore::DynamicNodeList::isDynamicNodeList):
     24        * dom/DynamicNodeList.h:
     25        (WebCore::DynamicNodeList::rootNode): Added the ability to get the node
     26        backing a NodeList, for use in the opaque roots system.
     27
     28        * dom/Node.cpp:
     29        * dom/Node.h:
     30        * dom/NodeList.h:
     31        (WebCore::NodeList::isDynamicNodeList): Ditto. Removed cruft related
     32        to the old way of marking NodeLists.
     33
     34        * dom/NodeList.idl: We need a custom toJS so we can specify a custom
     35        WeakHandleOwner at construction time.
     36
    1372011-04-19  Antoine Labour  <piman@chromium.org>
    238
  • trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r84194 r84309  
    5959    markDOMObjectWrapper(markStack, globalData, document->implementation());
    6060    markDOMObjectWrapper(markStack, globalData, document->styleSheets());
    61     document->markCachedNodeLists(markStack, globalData);
    6261}
    6362
  • trunk/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp

    r84194 r84309  
    2828
    2929#include "JSNode.h"
    30 
    3130#include "Element.h"
    3231#include "NamedNodeMap.h"
  • trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp

    r65588 r84309  
    2727#include "JSNodeList.h"
    2828
     29#include "DynamicNodeList.h"
    2930#include "JSNode.h"
    3031#include "Node.h"
     
    3536
    3637namespace WebCore {
     38
     39class JSNodeListOwner : public JSC::WeakHandleOwner {
     40    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     41    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     42};
     43
     44bool JSNodeListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
     45{
     46    JSNodeList* jsNodeList = static_cast<JSNodeList*>(handle.get().asCell());
     47    if (!jsNodeList->hasCustomProperties())
     48        return false;
     49    if (!jsNodeList->impl()->isDynamicNodeList())
     50        return false;
     51    return markStack.containsOpaqueRoot(root(static_cast<DynamicNodeList*>(jsNodeList->impl())->rootNode()));
     52}
     53
     54void JSNodeListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     55{
     56    JSNodeList* jsNodeList = static_cast<JSNodeList*>(handle.get().asCell());
     57    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     58    uncacheWrapper(world, jsNodeList->impl(), jsNodeList);
     59}
     60
     61inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, NodeList*)
     62{
     63    DEFINE_STATIC_LOCAL(JSNodeListOwner, jsNodeListOwner, ());
     64    return &jsNodeListOwner;
     65}
     66
     67inline void* wrapperContext(DOMWrapperWorld* world, NodeList*)
     68{
     69    return world;
     70}
     71
     72JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, NodeList* impl)
     73{
     74    return wrap<JSNodeList>(exec, globalObject, impl);
     75}
    3776
    3877// Need to support call so that list(0) works.
  • trunk/Source/WebCore/dom/DynamicNodeList.cpp

    r69868 r84309  
    146146}
    147147
     148bool DynamicNodeList::isDynamicNodeList() const
     149{
     150    return true;
     151}
     152
    148153void DynamicNodeList::invalidateCache()
    149154{
  • trunk/Source/WebCore/dom/DynamicNodeList.h

    r65021 r84309  
    6161        // Other methods (not part of DOM)
    6262        void invalidateCache();
     63        Node* rootNode() const { return m_rootNode.get(); }
    6364
    6465    protected:
     
    7374
    7475    private:
     76        virtual bool isDynamicNodeList() const;
    7577        Node* itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const;
    7678        Node* itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const;
  • trunk/Source/WebCore/dom/Node.cpp

    r84251 r84309  
    26522652}
    26532653
    2654 #if USE(JSC)
    2655 
    2656 template <class NodeListMap>
    2657 void markNodeLists(const NodeListMap& map, JSC::MarkStack& markStack, JSC::JSGlobalData& globalData)
    2658 {
    2659     for (typename NodeListMap::const_iterator it = map.begin(); it != map.end(); ++it)
    2660         markDOMObjectWrapper(markStack, globalData, it->second);
    2661 }
    2662 
    2663 void Node::markCachedNodeListsSlow(JSC::MarkStack& markStack, JSC::JSGlobalData& globalData)
    2664 {
    2665     NodeListsNodeData* nodeLists = rareData()->nodeLists();
    2666     if (!nodeLists)
    2667         return;
    2668 
    2669     markNodeLists(nodeLists->m_classNodeListCache, markStack, globalData);
    2670     markNodeLists(nodeLists->m_nameNodeListCache, markStack, globalData);
    2671     markNodeLists(nodeLists->m_tagNodeListCache, markStack, globalData);
    2672 }
    2673 
    2674 #endif
    2675 
    26762654void Node::handleLocalEvents(Event* event)
    26772655{
  • trunk/Source/WebCore/dom/Node.h

    r84251 r84309  
    573573    virtual EventTargetData* ensureEventTargetData();
    574574
    575 #if USE(JSC)
    576     void markCachedNodeLists(JSC::MarkStack& markStack, JSC::JSGlobalData& globalData)
    577     {
    578         // NodeLists may be present.  If so, they need to be marked.
    579         if (!hasRareData())
    580             return;
    581 
    582         markCachedNodeListsSlow(markStack, globalData);
    583     }
    584 #endif
    585 
    586575private:
    587576    enum NodeFlags {
     
    666655
    667656private:
    668 #if USE(JSC)
    669     void markCachedNodeListsSlow(JSC::MarkStack&, JSC::JSGlobalData&);
    670 #endif
    671 
    672657    enum EditableLevel { Editable, RichlyEditable };
    673658    bool rendererIsEditable(EditableLevel) const;
  • trunk/Source/WebCore/dom/NodeList.h

    r65021 r84309  
    4040        virtual Node* item(unsigned index) const = 0;
    4141        virtual Node* itemWithName(const AtomicString&) const = 0;
     42       
     43        // Other methods (not part of DOM)
     44        virtual bool isDynamicNodeList() const { return false; }
    4245    };
    4346
  • trunk/Source/WebCore/dom/NodeList.idl

    r52921 r84309  
    2222
    2323    interface [
     24        CustomToJS,
    2425        HasIndexGetter,
    2526        HasNameGetter,
Note: See TracChangeset for help on using the changeset viewer.