JSNodeListCustom.cpp [plain text]
#include "config.h"
#include "JSNodeList.h"
#include "ChildNodeList.h"
#include "JSNode.h"
#include "LiveNodeList.h"
#include "Node.h"
#include "NodeList.h"
#include <wtf/text/AtomicString.h>
using namespace JSC;
namespace WebCore {
bool JSNodeListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
JSNodeList* jsNodeList = jsCast<JSNodeList*>(handle.slot()->asCell());
if (!jsNodeList->hasCustomProperties())
return false;
if (jsNodeList->impl().isLiveNodeList())
return visitor.containsOpaqueRoot(root(static_cast<LiveNodeList&>(jsNodeList->impl()).ownerNode()));
if (jsNodeList->impl().isChildNodeList())
return visitor.containsOpaqueRoot(root(static_cast<ChildNodeList&>(jsNodeList->impl()).ownerNode()));
if (jsNodeList->impl().isEmptyNodeList())
return visitor.containsOpaqueRoot(root(static_cast<EmptyNodeList&>(jsNodeList->impl()).ownerNode()));
return false;
}
bool JSNodeList::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
if (Node* item = impl().namedItem(propertyNameToAtomicString(propertyName))) {
slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS(exec, globalObject(), item));
return true;
}
return false;
}
JSC::JSValue createWrapper(JSDOMGlobalObject& globalObject, NodeList& nodeList)
{
globalObject.vm().heap.deprecatedReportExtraMemory(nodeList.memoryCost());
return createNewWrapper<JSNodeList>(&globalObject, &nodeList);
}
}