[webkit-dev] Name Getters

Eric Seidel eric at webkit.org
Thu Jul 23 15:04:34 PDT 2009


Is it possible to move a name getter onto a different JavaScript object?


Example:
JSValue JSHTMLFormElement::nameGetter(ExecState* exec, const
Identifier& propertyName, const PropertySlot& slot)
{
    JSHTMLElement* jsForm =
static_cast<JSHTMLFormElement*>(asObject(slot.slotBase()));
    HTMLFormElement* form = static_cast<HTMLFormElement*>(jsForm->impl());

    Vector<RefPtr<Node> > namedItems;
    form->getNamedElements(propertyName, namedItems);

    if (namedItems.size() == 1)
        return toJS(exec, jsForm->globalObject(), namedItems[0].get());
    if (namedItems.size() > 1)
        return new (exec) JSNamedNodesCollection(exec,
jsForm->globalObject(), namedItems);
    return jsUndefined();
}

Why does this function use slot.slotBase() for "this" instead of just
using "this"?

Arv mentioned that there is lookupGetter()... maybe that's why this
uses slot.slotBase()?

-eric


More information about the webkit-dev mailing list