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) - Fix GetNativeOfWrapper/GetJSObjectOfWrapper/xpc_OkToHandOutWrapper/quickstubs to deal with the new DOM bindings. r=bz/jst/mrbkap.
--HG-- extra : rebase_source : 1b9afcc9d588ece15753fb36b249bc3a288e98c0
This commit is contained in:
parent
2980e5d4d8
commit
bfe49c1981
@ -503,6 +503,7 @@
|
|||||||
#include "nsIDOMCustomEvent.h"
|
#include "nsIDOMCustomEvent.h"
|
||||||
|
|
||||||
#include "nsWrapperCacheInlines.h"
|
#include "nsWrapperCacheInlines.h"
|
||||||
|
#include "dombindings.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
@ -8425,14 +8426,20 @@ nsHTMLDocumentSH::GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
|
|||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(collection)) {
|
if (!JSVAL_IS_PRIMITIVE(collection)) {
|
||||||
// We already have a node list in our reserved slot, use it.
|
// We already have a node list in our reserved slot, use it.
|
||||||
|
JSObject *obj = JSVAL_TO_OBJECT(collection);
|
||||||
nsISupports *native =
|
if (xpc::dom::NodeList<nsIHTMLCollection>::objIsNodeList(obj)) {
|
||||||
sXPConnect->GetNativeOfWrapper(cx, JSVAL_TO_OBJECT(collection));
|
nsIHTMLCollection *native =
|
||||||
if (native) {
|
xpc::dom::NodeList<nsIHTMLCollection>::getNodeList(obj);
|
||||||
NS_ADDREF(*nodeList = nsContentList::FromSupports(native));
|
NS_ADDREF(*nodeList = static_cast<nsContentList*>(native));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rv = NS_ERROR_FAILURE;
|
nsISupports *native = sXPConnect->GetNativeOfWrapper(cx, obj);
|
||||||
|
if (native) {
|
||||||
|
NS_ADDREF(*nodeList = nsContentList::FromSupports(native));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No node list for this document.all yet, create one...
|
// No node list for this document.all yet, create one...
|
||||||
|
@ -1019,5 +1019,9 @@ NodeList<T>::finalize(JSContext *cx, JSObject *proxy)
|
|||||||
NS_RELEASE(nodeList);
|
NS_RELEASE(nodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template
|
||||||
|
nsIHTMLCollection*
|
||||||
|
NodeList<nsIHTMLCollection>::getNodeList(JSObject *obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,6 @@ class NodeList : public NodeListBase {
|
|||||||
static bool instanceIsNodeListObject(JSContext *cx, JSObject *obj, JSObject *callee);
|
static bool instanceIsNodeListObject(JSContext *cx, JSObject *obj, JSObject *callee);
|
||||||
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, bool *enabled);
|
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, bool *enabled);
|
||||||
|
|
||||||
static T *getNodeList(JSObject *obj);
|
|
||||||
|
|
||||||
static JSObject *ensureExpandoObject(JSContext *cx, JSObject *obj);
|
static JSObject *ensureExpandoObject(JSContext *cx, JSObject *obj);
|
||||||
|
|
||||||
static uint32 getProtoShape(JSObject *obj);
|
static uint32 getProtoShape(JSObject *obj);
|
||||||
@ -178,6 +176,7 @@ class NodeList : public NodeListBase {
|
|||||||
{
|
{
|
||||||
return js::GetObjectClass(prototype) == &sInterfaceClass;
|
return js::GetObjectClass(prototype) == &sInterfaceClass;
|
||||||
}
|
}
|
||||||
|
static T *getNodeList(JSObject *obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1539,9 +1539,22 @@ nsXPConnect::GetNativeOfWrapper(JSContext * aJSContext,
|
|||||||
nsIXPConnectWrappedNative* wrapper =
|
nsIXPConnectWrappedNative* wrapper =
|
||||||
XPCWrappedNative::GetWrappedNativeOfJSObject(aJSContext, aJSObj, nsnull,
|
XPCWrappedNative::GetWrappedNativeOfJSObject(aJSContext, aJSObj, nsnull,
|
||||||
&obj2);
|
&obj2);
|
||||||
|
if(wrapper)
|
||||||
|
return wrapper->Native();
|
||||||
|
|
||||||
return wrapper ? wrapper->Native() :
|
if(obj2)
|
||||||
(obj2 ? (nsISupports*)xpc_GetJSPrivate(obj2) : nsnull);
|
return (nsISupports*)xpc_GetJSPrivate(obj2);
|
||||||
|
|
||||||
|
if(xpc::dom::instanceIsProxy(aJSObj)) {
|
||||||
|
// FIXME: Provide a fast non-refcounting way to get the canonical
|
||||||
|
// nsISupports from the proxy.
|
||||||
|
nsISupports *supports =
|
||||||
|
static_cast<nsISupports*>(js::GetProxyPrivate(aJSObj).toPrivate());
|
||||||
|
nsCOMPtr<nsISupports> canonical = do_QueryInterface(supports);
|
||||||
|
return canonical.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* JSObjectPtr getJSObjectOfWrapper (in JSContextPtr aJSContext, in JSObjectPtr aJSObj); */
|
/* JSObjectPtr getJSObjectOfWrapper (in JSContextPtr aJSContext, in JSObjectPtr aJSObj); */
|
||||||
@ -1572,6 +1585,11 @@ nsXPConnect::GetJSObjectOfWrapper(JSContext * aJSContext,
|
|||||||
*_retval = obj2;
|
*_retval = obj2;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
if(xpc::dom::instanceIsProxy(aJSObj))
|
||||||
|
{
|
||||||
|
*_retval = aJSObj;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
// else...
|
// else...
|
||||||
*_retval = nsnull;
|
*_retval = nsnull;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -875,13 +875,31 @@ castNative(JSContext *cx,
|
|||||||
}
|
}
|
||||||
else if(cur)
|
else if(cur)
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(IS_SLIM_WRAPPER(cur), "should be a slim wrapper");
|
nsISupports *native;
|
||||||
nsISupports *native = static_cast<nsISupports*>(xpc_GetJSPrivate(cur));
|
QITableEntry *entries;
|
||||||
if(NS_SUCCEEDED(getNative(native, GetOffsetsFromSlimWrapper(cur),
|
if(IS_SLIM_WRAPPER(cur))
|
||||||
cur, iid, ppThis, pThisRef, vp)))
|
{
|
||||||
|
native = static_cast<nsISupports*>(xpc_GetJSPrivate(cur));
|
||||||
|
entries = GetOffsetsFromSlimWrapper(cur);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NS_ABORT_IF_FALSE(xpc::dom::instanceIsProxy(cur),
|
||||||
|
"what kind of wrapper is this?");
|
||||||
|
native = static_cast<nsISupports*>(js::GetProxyPrivate(cur).toPrivate());
|
||||||
|
entries = nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NS_SUCCEEDED(getNative(native, entries, cur, iid, ppThis, pThisRef, vp)))
|
||||||
{
|
{
|
||||||
if(lccx)
|
if(lccx)
|
||||||
|
{
|
||||||
|
// This only matters for unwrapping of this objects, so we
|
||||||
|
// shouldn't end up here for the new DOM bindings.
|
||||||
|
NS_ABORT_IF_FALSE(IS_SLIM_WRAPPER(cur),
|
||||||
|
"what kind of wrapper is this?");
|
||||||
lccx->SetWrapper(cur);
|
lccx->SetWrapper(cur);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -953,8 +971,16 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
|
|||||||
XPCWrappedNative *wrapper;
|
XPCWrappedNative *wrapper;
|
||||||
XPCWrappedNativeTearOff *tearoff;
|
XPCWrappedNativeTearOff *tearoff;
|
||||||
JSObject *obj2;
|
JSObject *obj2;
|
||||||
rv = getWrapper(cx, src, nsnull, &wrapper, &obj2, &tearoff);
|
if(xpc::dom::instanceIsProxy(src))
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
{
|
||||||
|
wrapper = nsnull;
|
||||||
|
obj2 = src;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rv = getWrapper(cx, src, nsnull, &wrapper, &obj2, &tearoff);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
|
||||||
if(wrapper || obj2)
|
if(wrapper || obj2)
|
||||||
{
|
{
|
||||||
|
@ -60,16 +60,10 @@ xpc_OkToHandOutWrapper(nsWrapperCache *cache)
|
|||||||
NS_ABORT_IF_FALSE(cache->GetWrapper(), "Must have wrapper");
|
NS_ABORT_IF_FALSE(cache->GetWrapper(), "Must have wrapper");
|
||||||
NS_ABORT_IF_FALSE(cache->IsProxy() || IS_WN_WRAPPER(cache->GetWrapper()),
|
NS_ABORT_IF_FALSE(cache->IsProxy() || IS_WN_WRAPPER(cache->GetWrapper()),
|
||||||
"Must have proxy or XPCWrappedNative wrapper");
|
"Must have proxy or XPCWrappedNative wrapper");
|
||||||
NS_ABORT_IF_FALSE(cache->IsProxy() == js::IsProxy(cache->GetWrapper()),
|
return cache->IsProxy() ?
|
||||||
"There's serious confusion about whether this is a "
|
xpc::dom::instanceIsProxy(cache->GetWrapper()) :
|
||||||
"proxy");
|
!static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cache->GetWrapper()))->
|
||||||
return
|
NeedsSOW();
|
||||||
(cache->IsProxy() &&
|
|
||||||
js::GetProxyHandler(cache->GetWrapper())->family() ==
|
|
||||||
xpc::dom::ProxyFamily()) ||
|
|
||||||
(!cache->IsProxy() &&
|
|
||||||
!static_cast<XPCWrappedNative*>(xpc_GetJSPrivate(cache->GetWrapper()))->
|
|
||||||
NeedsSOW());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user