Bug 480975 - Make document fragments participate correctly in the wrapper cache. r+sr=jst

This commit is contained in:
Blake Kaplan 2009-03-20 16:14:14 -07:00
parent c0d5aa90c8
commit 53cf9b6134
2 changed files with 50 additions and 3 deletions

View File

@ -637,8 +637,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DocumentFragment, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DocumentFragment, nsDocumentFragmentSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_FINALIZE)
NS_DEFINE_CLASSINFO_DATA(Element, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Attr, nsAttributeSH,
@ -7117,7 +7118,29 @@ nsNodeSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
// DocumentFragment helper.
NS_IMETHODIMP
nsDocumentFragmentSH::PostCreate(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj)
{
nsINode* node = static_cast<nsINode*>(wrapper->Native());
node->SetWrapper(wrapper);
return nsDOMGenericSH::PostCreate(wrapper, cx, obj);
}
NS_IMETHODIMP
nsDocumentFragmentSH::Finalize(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj)
{
nsINode* node = static_cast<nsINode*>(wrapper->Native());
node->ClearWrapper();
return NS_OK;
}
// EventReceiver helper
// static

View File

@ -354,6 +354,30 @@ public:
typedef nsDOMClassInfo nsDOMGenericSH;
class nsDocumentFragmentSH : public nsDOMGenericSH
{
protected:
nsDocumentFragmentSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
{
}
virtual ~nsDocumentFragmentSH()
{
}
public:
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj);
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsDocumentFragmentSH(aData);
}
};
// EventProp scriptable helper, this class should be the base class of
// all objects that should support things like
// obj.onclick=function{...}