Status: New
Owner: ----

New issue 2075 by [email protected]: Implement AccessorInfo.IsInstanceOf()
http://code.google.com/p/v8/issues/detail?id=2075

Currently a DOM attribute is defined on a DOM object, but the Web IDL spec requires that a DOM attribute should be defined on the prototype chain.

If we define the DOM attribute on the prototype chain, the V8 binding needs to check whether the DOM attribute is implemented in 'this'. For example, consider the following case:

    var xhr = new XMLHttpRequest();
    xhr.__proto__ = HTMLElement.prototype;
    xhr.lang;    // Crash!!

To avoid such kind of crash, the V8 binding needs to insert the "instance-of" check, like this:

static v8::Handle<v8::Value> langAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
    {
if (!V8HTMLElement::GetTemplate()->HasInstance(info.This())) /* The "instance-of" check. This checks whether 'lang' is defined on 'this'. */
            return throwError(V8Proxy::TypeError);
        Element* imp = V8Element::toNative(info.This());
        return v8ExternalString(imp->getAttribute(HTMLNames::langAttr));
    }

This works correctly. However, doing the "instance-of" check in the V8 binding side is too heavy. Considering the fact that V8 already knows the result of the "instance-of" check before calling back langAttrGetter(), V8 can include the result of the "instance-of" check into AccessorInfo. In other words, we want AccessorInfo.IsInstanceOf().

For more details (viewable from google internal only): https://docs.google.com/a/google.com/document/d/1ldrDdfcwij5_juqvRpI_Rq20SgWiR88c4DUFvkQ0olU/edit


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to