JSWebKitPointConstructor.cpp [plain text]
#include "config.h"
#include "JSWebKitPointConstructor.h"
#include "Document.h"
#include "WebKitPoint.h"
#include "JSWebKitPoint.h"
namespace WebCore {
using namespace KJS;
JSWebKitPointConstructor::JSWebKitPointConstructor(ExecState* exec, Document* d)
: KJS::DOMObject(exec->lexicalGlobalObject()->objectPrototype())
, m_doc(d)
{
put(exec, exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
}
bool JSWebKitPointConstructor::implementsConstruct() const
{
return true;
}
JSObject* JSWebKitPointConstructor::construct(ExecState* exec, const List& args)
{
float x = 0;
float y = 0;
if (args.size() >= 2) {
x = (float) args[0]->getNumber();
y = (float) args[1]->getNumber();
if (isnan(x))
x = 0;
if (isnan(y))
y = 0;
}
return static_cast<JSObject*>(toJS(exec, new WebKitPoint(x, y)));
}
}