mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 648801 (new DOM list bindings) - Make HTMLCollection['string'] work. r=bz/jst/mrbkap.
--HG-- extra : rebase_source : 7f61b1f61526c265c70de518086aeef8f20347bd
This commit is contained in:
parent
c34c19ed9f
commit
ad471c7e2b
@ -96,10 +96,6 @@ Class NodeList<nsINodeList>::sProtoClass = {
|
||||
JS_ConvertStub
|
||||
};
|
||||
|
||||
template<>
|
||||
JSBool
|
||||
NodeList<nsINodeList>::namedItem(JSContext *cx, uintN argc, jsval *vp);
|
||||
|
||||
template<>
|
||||
NodeList<nsINodeList>::Methods NodeList<nsINodeList>::sProtoMethods[] = {
|
||||
{ nsDOMClassInfo::sItem_id, &item, 1 }
|
||||
@ -219,6 +215,26 @@ NodeList<T>::item(JSContext *cx, uintN argc, jsval *vp)
|
||||
return WrapObject(cx, obj, result, result, vp);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
JSBool
|
||||
NodeList<nsIHTMLCollection>::namedItem(JSContext *cx, JSObject *obj, jsval *name, jsval *vp)
|
||||
{
|
||||
xpc_qsDOMString nameString(cx, *name, name,
|
||||
xpc_qsDOMString::eDefaultNullBehavior,
|
||||
xpc_qsDOMString::eDefaultUndefinedBehavior);
|
||||
if (!nameString.IsValid())
|
||||
return JS_FALSE;
|
||||
nsIHTMLCollection *collection = getNodeList(obj);
|
||||
nsWrapperCache *cache;
|
||||
nsISupports *result = collection->GetNamedItem(nameString, &cache);
|
||||
if (!result) {
|
||||
*vp = JSVAL_NULL;
|
||||
return JS_TRUE;
|
||||
}
|
||||
return WrapObject(cx, obj, result, cache, vp);
|
||||
}
|
||||
|
||||
template<>
|
||||
JSBool
|
||||
NodeList<nsIHTMLCollection>::namedItem(JSContext *cx, uintN argc, jsval *vp)
|
||||
@ -230,15 +246,7 @@ NodeList<nsIHTMLCollection>::namedItem(JSContext *cx, uintN argc, jsval *vp)
|
||||
if (argc < 1)
|
||||
return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
xpc_qsDOMString name(cx, argv[0], &argv[0],
|
||||
xpc_qsDOMString::eDefaultNullBehavior,
|
||||
xpc_qsDOMString::eDefaultUndefinedBehavior);
|
||||
if (!name.IsValid())
|
||||
return JS_FALSE;
|
||||
nsIHTMLCollection *htmlCollection = getNodeList(obj);
|
||||
nsWrapperCache *cache;
|
||||
nsISupports *result = htmlCollection->GetNamedItem(name, &cache);
|
||||
return WrapObject(cx, obj, result, cache, vp);
|
||||
return namedItem(cx, obj, &argv[0], vp);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@ -575,6 +583,26 @@ NodeList<T>::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, Property
|
||||
return true;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline bool
|
||||
NodeList<nsINodeList>::namedItem(JSContext *cx, JSObject *proxy, jsid id, Value *vp, bool *result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
template<>
|
||||
inline bool
|
||||
NodeList<nsIHTMLCollection>::namedItem(JSContext *cx, JSObject *proxy, jsid id, Value *vp, bool *result)
|
||||
{
|
||||
if (!JSID_IS_STRING(id))
|
||||
return false;
|
||||
|
||||
jsval v = STRING_TO_JSVAL(JSID_TO_STRING(id));
|
||||
*result = namedItem(cx, proxy, &v, vp);
|
||||
|
||||
// We treat failure as having handled the get.
|
||||
return !*result || !vp->isNull();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool
|
||||
NodeList<T>::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp)
|
||||
@ -597,6 +625,10 @@ NodeList<T>::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Va
|
||||
return WrapObject(cx, proxy, result, result, vp);
|
||||
}
|
||||
|
||||
bool ok;
|
||||
if (namedItem(cx, proxy, id, vp, &ok))
|
||||
return ok;
|
||||
|
||||
JSObject *proto = js::GetObjectProto(proxy);
|
||||
bool hit;
|
||||
if (!checkForCacheHit(cx, proxy, receiver, proto, id, vp, &hit))
|
||||
|
@ -92,6 +92,9 @@ class NodeList : public NodeListBase {
|
||||
static JSBool item(JSContext *cx, uintN argc, jsval *vp);
|
||||
static JSBool namedItem(JSContext *cx, uintN argc, jsval *vp);
|
||||
|
||||
static JSBool namedItem(JSContext *cx, JSObject *obj, jsval *name, jsval *vp);
|
||||
static bool namedItem(JSContext *cx, JSObject *proxy, jsid id, js::Value *vp, bool *result);
|
||||
|
||||
static bool cacheProtoShape(JSContext *cx, JSObject *proxy, JSObject *proto);
|
||||
static bool checkForCacheHit(JSContext *cx, JSObject *proxy, JSObject *receiver, JSObject *proto,
|
||||
jsid id, js::Value *vp, bool *hitp);
|
||||
|
Loading…
Reference in New Issue
Block a user