JSNodeListCustom.cpp [plain text]
#include "config.h"
#include "JSNodeList.h"
#include "DynamicNodeList.h"
#include "JSNode.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 = static_cast<JSNodeList*>(handle.get().asCell());
if (!jsNodeList->hasCustomProperties())
return false;
if (!jsNodeList->impl()->isDynamicNodeList())
return false;
return visitor.containsOpaqueRoot(root(static_cast<DynamicNodeList*>(jsNodeList->impl())->rootNode()));
}
static EncodedJSValue JSC_HOST_CALL callNodeList(ExecState* exec)
{
bool ok;
unsigned index = Identifier::toUInt32(exec->argument(0).toString(exec), ok);
if (!ok)
return JSValue::encode(jsUndefined());
JSNodeList* thisObj = static_cast<JSNodeList*>(exec->callee());
return JSValue::encode(toJS(exec, thisObj->globalObject(), thisObj->impl()->item(index)));
}
CallType JSNodeList::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callNodeList;
return CallTypeHost;
}
bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, const Identifier& propertyName)
{
return impl->itemWithName(identifierToAtomicString(propertyName));
}
JSValue JSNodeList::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
JSNodeList* thisObj = static_cast<JSNodeList*>(asObject(slotBase));
return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(identifierToAtomicString(propertyName)));
}
}