JSHTMLCollectionCustom.cpp [plain text]
#include "config.h"
#include "JSHTMLCollection.h"
#include "HTMLAllCollection.h"
#include "HTMLCollection.h"
#include "HTMLFormControlsCollection.h"
#include "HTMLOptionsCollection.h"
#include "HTMLPropertiesCollection.h"
#include "JSDOMBinding.h"
#include "JSHTMLAllCollection.h"
#include "JSHTMLFormControlsCollection.h"
#include "JSHTMLOptionsCollection.h"
#include "JSNode.h"
#include "JSNodeList.h"
#include "JSRadioNodeList.h"
#include "Node.h"
#include "PropertyNodeList.h"
#include "RadioNodeList.h"
#include "StaticNodeList.h"
#include <wtf/Vector.h>
#include <wtf/text/AtomicString.h>
using namespace JSC;
namespace WebCore {
bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection, PropertyName propertyName)
{
return collection->hasNamedItem(propertyNameToAtomicString(propertyName));
}
JSValue JSHTMLCollection::nameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
{
JSHTMLCollection* collection = jsCast<JSHTMLCollection*>(asObject(slotBase));
const AtomicString& name = propertyNameToAtomicString(propertyName);
HTMLCollection* impl = collection->impl();
#if ENABLE(MICRODATA)
if (impl->type() == ItemProperties)
return toJS(exec, collection->globalObject(), static_cast<HTMLPropertiesCollection*>(impl)->propertyNodeList(name));
#endif
return toJS(exec, collection->globalObject(), impl->namedItem(name));
}
JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* collection)
{
if (!collection)
return jsNull();
JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), collection);
if (wrapper)
return wrapper;
switch (collection->type()) {
case FormControls:
return CREATE_DOM_WRAPPER(exec, globalObject, HTMLFormControlsCollection, collection);
case SelectOptions:
return CREATE_DOM_WRAPPER(exec, globalObject, HTMLOptionsCollection, collection);
case DocAll:
return CREATE_DOM_WRAPPER(exec, globalObject, HTMLAllCollection, collection);
default:
break;
}
return CREATE_DOM_WRAPPER(exec, globalObject, HTMLCollection, collection);
}
}