JSDOMStringMapCustom.cpp [plain text]
#include "config.h"
#include "JSDOMStringMap.h"
#include "DOMStringMap.h"
#include "Element.h"
#include "JSNode.h"
#include <wtf/text/AtomicString.h>
using namespace JSC;
namespace WebCore {
bool JSDOMStringMap::canGetItemsForName(ExecState*, DOMStringMap* impl, const Identifier& propertyName)
{
return impl->contains(identifierToAtomicString(propertyName));
}
JSValue JSDOMStringMap::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
JSDOMStringMap* thisObj = static_cast<JSDOMStringMap*>(asObject(slotBase));
return jsString(exec, thisObj->impl()->item(identifierToAtomicString(propertyName)));
}
void JSDOMStringMap::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
Vector<String> names;
m_impl->getNames(names);
size_t length = names.size();
for (size_t i = 0; i < length; ++i)
propertyNames.add(Identifier(exec, stringToUString(names[i])));
Base::getOwnPropertyNames(exec, propertyNames, mode);
}
bool JSDOMStringMap::deleteProperty(ExecState* exec, const Identifier& propertyName)
{
PropertySlot slot;
if (getStaticValueSlot<JSDOMStringMap, Base>(exec, s_info.propHashTable(exec), this, propertyName, slot))
return false;
JSValue prototype = this->prototype();
if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName))
return false;
ExceptionCode ec = 0;
m_impl->deleteItem(identifierToString(propertyName), ec);
setDOMException(exec, ec);
return true;
}
bool JSDOMStringMap::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot&)
{
PropertySlot slot;
if (getStaticValueSlot<JSDOMStringMap, Base>(exec, s_info.propHashTable(exec), this, propertyName, slot))
return false;
JSValue prototype = this->prototype();
if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName))
return false;
String stringValue = ustringToString(value.toString(exec));
if (exec->hadException())
return true;
ExceptionCode ec = 0;
impl()->setItem(identifierToString(propertyName), stringValue, ec);
setDOMException(exec, ec);
return true;
}
}