webengine/osswebengine/DerivedSources/WebCore/JSHTMLLabelElement.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 16:07:13 +0300
changeset 66 cacf6ee57968
parent 0 dd21522fd290
permissions -rw-r--r--
Revision: 201006 Kit: 201015

/*
    This file is part of the WebKit open source project.
    This file has been generated by generate-bindings.pl. DO NOT MODIFY!

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include "config.h"

#include "JSHTMLLabelElement.h"

#include <wtf/GetPtr.h>

#include "HTMLFormElement.h"
#include "HTMLLabelElement.h"
#include "JSHTMLFormElement.h"
#include "PlatformString.h"

using namespace KJS;

namespace WebCore {

/* Hash table */

static const HashEntry JSHTMLLabelElementTableEntries[] =
{
    { 0, 0, 0, 0, 0 },
    { "form", JSHTMLLabelElement::FormAttrNum, DontDelete|ReadOnly, 0, &JSHTMLLabelElementTableEntries[4] },
    { "accessKey", JSHTMLLabelElement::AccessKeyAttrNum, DontDelete, 0, 0 },
    { 0, 0, 0, 0, 0 },
    { "htmlFor", JSHTMLLabelElement::HtmlForAttrNum, DontDelete, 0, &JSHTMLLabelElementTableEntries[5] },
    { "constructor", JSHTMLLabelElement::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }
};

static const HashTable JSHTMLLabelElementTable = 
{
    2, 6, JSHTMLLabelElementTableEntries, 4
};

/* Hash table for constructor */

static const HashEntry JSHTMLLabelElementConstructorTableEntries[] =
{
    { 0, 0, 0, 0, 0 }
};

static const HashTable JSHTMLLabelElementConstructorTable = 
{
    2, 1, JSHTMLLabelElementConstructorTableEntries, 1
};

class JSHTMLLabelElementConstructor : public DOMObject {
public:
    JSHTMLLabelElementConstructor(ExecState* exec)
    {
        setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
        putDirect(exec->propertyNames().prototype, JSHTMLLabelElementPrototype::self(exec), None);
    }
    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    JSValue* getValueProperty(ExecState*, int token) const;
    virtual const ClassInfo* classInfo() const { return &info; }
    static const ClassInfo info;

    virtual bool implementsHasInstance() const { return true; }
};

const ClassInfo JSHTMLLabelElementConstructor::info = { "HTMLLabelElementConstructor", 0, &JSHTMLLabelElementConstructorTable, 0 };

bool JSHTMLLabelElementConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSHTMLLabelElementConstructor, DOMObject>(exec, &JSHTMLLabelElementConstructorTable, this, propertyName, slot);
}

JSValue* JSHTMLLabelElementConstructor::getValueProperty(ExecState*, int token) const
{
    // The token is the numeric value of its associated constant
    return jsNumber(token);
}

/* Hash table for prototype */

static const HashEntry JSHTMLLabelElementPrototypeTableEntries[] =
{
    { "focus", JSHTMLLabelElement::FocusFuncNum, DontDelete|Function, 0, 0 }
};

static const HashTable JSHTMLLabelElementPrototypeTable = 
{
    2, 1, JSHTMLLabelElementPrototypeTableEntries, 1
};

const ClassInfo JSHTMLLabelElementPrototype::info = { "HTMLLabelElementPrototype", 0, &JSHTMLLabelElementPrototypeTable, 0 };

JSObject* JSHTMLLabelElementPrototype::self(ExecState* exec)
{
    return KJS::cacheGlobalObject<JSHTMLLabelElementPrototype>(exec, "[[JSHTMLLabelElement.prototype]]");
}

bool JSHTMLLabelElementPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticFunctionSlot<JSHTMLLabelElementPrototypeFunction, JSObject>(exec, &JSHTMLLabelElementPrototypeTable, this, propertyName, slot);
}

const ClassInfo JSHTMLLabelElement::info = { "HTMLLabelElement", &JSHTMLElement::info, &JSHTMLLabelElementTable, 0 };

JSHTMLLabelElement::JSHTMLLabelElement(ExecState* exec, HTMLLabelElement* impl)
    : JSHTMLElement(exec, impl)
{
    setPrototype(JSHTMLLabelElementPrototype::self(exec));
}

bool JSHTMLLabelElement::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSHTMLLabelElement, JSHTMLElement>(exec, &JSHTMLLabelElementTable, this, propertyName, slot);
}

JSValue* JSHTMLLabelElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case FormAttrNum: {
        HTMLLabelElement* imp = static_cast<HTMLLabelElement*>(impl());

        return toJS(exec, WTF::getPtr(imp->form()));
    }
    case AccessKeyAttrNum: {
        HTMLLabelElement* imp = static_cast<HTMLLabelElement*>(impl());

        return jsString(imp->accessKey());
    }
    case HtmlForAttrNum: {
        HTMLLabelElement* imp = static_cast<HTMLLabelElement*>(impl());

        return jsString(imp->htmlFor());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}

void JSHTMLLabelElement::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
    lookupPut<JSHTMLLabelElement, JSHTMLElement>(exec, propertyName, value, attr, &JSHTMLLabelElementTable, this);
}

void JSHTMLLabelElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
    switch (token) {
    case AccessKeyAttrNum: {
        HTMLLabelElement* imp = static_cast<HTMLLabelElement*>(impl());

        imp->setAccessKey(valueToStringWithNullCheck(exec, value));
        break;
    }
    case HtmlForAttrNum: {
        HTMLLabelElement* imp = static_cast<HTMLLabelElement*>(impl());

        imp->setHtmlFor(valueToStringWithNullCheck(exec, value));
        break;
    }
    }
}

JSValue* JSHTMLLabelElement::getConstructor(ExecState* exec)
{
    return KJS::cacheGlobalObject<JSHTMLLabelElementConstructor>(exec, "[[HTMLLabelElement.constructor]]");
}
JSValue* JSHTMLLabelElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSHTMLLabelElement::info))
      return throwError(exec, TypeError);

    HTMLLabelElement* imp = static_cast<HTMLLabelElement*>(static_cast<JSHTMLLabelElement*>(thisObj)->impl());

    switch (id) {
    case JSHTMLLabelElement::FocusFuncNum: {

        imp->focus();
        return jsUndefined();
    }
    }
    return 0;
}

}