mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 812333 (Replace Node quickstubs with new binding methods) - part 1: make WrapNewBindingObject asserts deal with HTMLCollection. r=bz.
This commit is contained in:
parent
3fb06020ff
commit
f7c73dc555
@ -471,6 +471,29 @@ public:
|
||||
sizeof(Check<T>(nullptr)) == sizeof(yes);
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
template <class T, bool isISupports=IsISupports<T>::Value>
|
||||
struct
|
||||
CheckWrapperCacheCast
|
||||
{
|
||||
static bool Check()
|
||||
{
|
||||
return reinterpret_cast<uintptr_t>(
|
||||
static_cast<nsWrapperCache*>(
|
||||
reinterpret_cast<T*>(1))) == 1;
|
||||
}
|
||||
};
|
||||
template <class T>
|
||||
struct
|
||||
CheckWrapperCacheCast<T, true>
|
||||
{
|
||||
static bool Check()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// Create a JSObject wrapping "value", for cases when "value" is a
|
||||
// non-wrapper-cached object using WebIDL bindings. "value" must implement a
|
||||
// WrapObject() method taking a JSContext and a scope.
|
||||
@ -500,21 +523,21 @@ WrapNewBindingObject(JSContext* cx, JSObject* scope, T* value, JS::Value* vp)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// Some sanity asserts about our object. Specifically:
|
||||
// 1) If our class claims we're nsISupports, we better be nsISupports
|
||||
// XXXbz ideally, we could assert that reinterpret_cast to nsISupports
|
||||
// does the right thing, but I don't see a way to do it. :(
|
||||
// 2) If our class doesn't claim we're nsISupports we better be
|
||||
// reinterpret_castable to nsWrapperCache.
|
||||
const DOMClass* clasp = nullptr;
|
||||
DOMObjectSlot slot = GetDOMClass(obj, clasp);
|
||||
MOZ_ASSERT(slot != eNonDOMObject, "Totally unexpected object here");
|
||||
MOZ_ASSERT(clasp, "What happened here?");
|
||||
MOZ_ASSERT_IF(clasp->mDOMObjectIsISupports, IsISupports<T>::Value);
|
||||
// MOZ_ASSERT_IF(!clasp->mDOMObjectIsISupports,
|
||||
// reinterpret_cast<uintptr_t>(
|
||||
// static_cast<nsWrapperCache*>(
|
||||
// reinterpret_cast<T*>(1))) == 1);
|
||||
// slot can be eNonDOMObject if the cache contained a non-DOM object from a
|
||||
// different compartment than scope.
|
||||
if (slot != eNonDOMObject) {
|
||||
// Some sanity asserts about our object. Specifically:
|
||||
// 1) If our class claims we're nsISupports, we better be nsISupports
|
||||
// XXXbz ideally, we could assert that reinterpret_cast to nsISupports
|
||||
// does the right thing, but I don't see a way to do it. :(
|
||||
// 2) If our class doesn't claim we're nsISupports we better be
|
||||
// reinterpret_castable to nsWrapperCache.
|
||||
MOZ_ASSERT(clasp, "What happened here?");
|
||||
MOZ_ASSERT_IF(clasp->mDOMObjectIsISupports, IsISupports<T>::Value);
|
||||
MOZ_ASSERT(CheckWrapperCacheCast<T>::Check());
|
||||
}
|
||||
#endif
|
||||
|
||||
// When called via XrayWrapper, we end up here while running in the
|
||||
|
Loading…
Reference in New Issue
Block a user