JSNamedNodeMapCustom.cpp [plain text]
#include "config.h"
#include "JSNamedNodeMap.h"
#include "JSNode.h"
#include "Element.h"
#include "NamedNodeMap.h"
using namespace JSC;
namespace WebCore {
JSValue JSNamedNodeMap::setNamedItem(ExecState* exec, const ArgList& args)
{
NamedNodeMap* imp = static_cast<NamedNodeMap*>(impl());
ExceptionCode ec = 0;
Node* newNode = toNode(args.at(0));
if (newNode && newNode->nodeType() == Node::ATTRIBUTE_NODE && imp->element()) {
if (!allowSettingSrcToJavascriptURL(exec, imp->element(), newNode->nodeName(), newNode->nodeValue()))
return jsNull();
}
JSValue result = toJS(exec, globalObject(), WTF::getPtr(imp->setNamedItem(newNode, ec)));
setDOMException(exec, ec);
return result;
}
JSValue JSNamedNodeMap::setNamedItemNS(ExecState* exec, const ArgList& args)
{
NamedNodeMap* imp = static_cast<NamedNodeMap*>(impl());
ExceptionCode ec = 0;
Node* newNode = toNode(args.at(0));
if (newNode && newNode->nodeType() == Node::ATTRIBUTE_NODE && imp->element()) {
if (!allowSettingSrcToJavascriptURL(exec, imp->element(), newNode->nodeName(), newNode->nodeValue()))
return jsNull();
}
JSValue result = toJS(exec, globalObject(), WTF::getPtr(imp->setNamedItemNS(newNode, ec)));
setDOMException(exec, ec);
return result;
}
bool JSNamedNodeMap::canGetItemsForName(ExecState*, NamedNodeMap* impl, const Identifier& propertyName)
{
return impl->getNamedItem(propertyName);
}
JSValue JSNamedNodeMap::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(asObject(slot.slotBase()));
return toJS(exec, thisObj->impl()->getNamedItem(propertyName));
}
void JSNamedNodeMap::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
if (Element* element = impl()->element())
markDOMNodeWrapper(markStack, element->document(), element);
}
}