[webkit-dev] Name Getters

Eric Seidel eric at webkit.org
Thu Jul 23 15:13:50 PDT 2009


Ah!  Nevermind.  nameGetter is static.

    static JSC::JSValue nameGetter(JSC::ExecState*, const
JSC::Identifier&, const JSC::PropertySlot&);

-eric

On Thu, Jul 23, 2009 at 3:04 PM, Eric Seidel<eric at webkit.org> wrote:
> 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