Fix for bug 480389 (Remove nsIDocument's cached JS object). r/sr=jst.

--HG--
extra : rebase_source : 7e971c32cc922fb866f12f3e037f8c91c09df3bf
This commit is contained in:
Peter Van der Beken 2009-03-18 18:56:38 +01:00
Родитель cd79d0282b
Коммит 67c9b51850
4 изменённых файлов: 11 добавлений и 43 удалений

Просмотреть файл

@ -101,8 +101,8 @@ class nsFrameLoader;
// IID for the nsIDocument interface // IID for the nsIDocument interface
#define NS_IDOCUMENT_IID \ #define NS_IDOCUMENT_IID \
{ 0xdd9bd470, 0x6315, 0x4e67, \ { 0x6e467d95, 0x9934, 0x422a, \
{ 0xa8, 0x8a, 0x78, 0xbf, 0x92, 0xb4, 0x5a, 0xdf } } { 0x81, 0x07, 0x3f, 0xff, 0xe1, 0x38, 0xe6, 0x1e } }
// Flag for AddStyleSheet(). // Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0) #define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -125,8 +125,7 @@ public:
mCompatMode(eCompatibility_FullStandards), mCompatMode(eCompatibility_FullStandards),
mIsInitialDocumentInWindow(PR_FALSE), mIsInitialDocumentInWindow(PR_FALSE),
mMayStartLayout(PR_TRUE), mMayStartLayout(PR_TRUE),
mPartID(0), mPartID(0)
mJSObject(nsnull)
{ {
mParentPtrBits |= PARENT_BIT_INDOCUMENT; mParentPtrBits |= PARENT_BIT_INDOCUMENT;
} }
@ -995,16 +994,6 @@ public:
mMayStartLayout = aMayStartLayout; mMayStartLayout = aMayStartLayout;
} }
JSObject* GetJSObject() const
{
return mJSObject;
}
void SetJSObject(JSObject *aJSObject)
{
mJSObject = aJSObject;
}
// This method should return an addrefed nsIParser* or nsnull. Implementations // This method should return an addrefed nsIParser* or nsnull. Implementations
// should transfer ownership of the parser to the caller. // should transfer ownership of the parser to the caller.
virtual already_AddRefed<nsIParser> GetFragmentParser() { virtual already_AddRefed<nsIParser> GetFragmentParser() {
@ -1247,12 +1236,6 @@ protected:
nsCOMPtr<nsIDocument> mDisplayDocument; nsCOMPtr<nsIDocument> mDisplayDocument;
PRUint32 mEventsSuppressed; PRUint32 mEventsSuppressed;
private:
// JSObject cache. Only to be used for performance
// optimizations. This will be set once this document is touched
// from JS, and it will be unset once the JSObject is finalized.
JSObject *mJSObject;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)

Просмотреть файл

@ -6986,9 +6986,14 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
// to wrap here? But that's not always reachable, let's use // to wrap here? But that's not always reachable, let's use
// globalObj for now... // globalObj for now...
if (native_parent == doc && (*parentObj = doc->GetJSObject())) { nsIXPConnectJSObjectHolder *wrapper;
if (native_parent == doc &&
(wrapper = static_cast<nsIXPConnectJSObjectHolder*>(doc->GetWrapper()))) {
wrapper->GetJSObject(parentObj);
if(*parentObj) {
return NS_OK; return NS_OK;
} }
}
jsval v; jsval v;
nsCOMPtr<nsIXPConnectJSObjectHolder> holder; nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
@ -8251,10 +8256,6 @@ nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
// Cache the document's JSObject on the document so we can optimize
// nsNodeSH::PreCreate() to avoid nested WrapNative() calls.
doc->SetJSObject(obj);
nsresult rv = nsNodeSH::PostCreate(wrapper, cx, obj); nsresult rv = nsNodeSH::PostCreate(wrapper, cx, obj);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -8288,20 +8289,6 @@ nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDocumentSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj)
{
nsCOMPtr<nsIDocument> doc = do_QueryWrappedNative(wrapper);
if (!doc) {
return NS_ERROR_UNEXPECTED;
}
doc->SetJSObject(nsnull);
return nsNodeSH::Finalize(wrapper, cx, obj);
}
// HTMLDocument helper // HTMLDocument helper
// static // static

Просмотреть файл

@ -864,8 +864,6 @@ public:
NS_IMETHOD GetFlags(PRUint32* aFlags); NS_IMETHOD GetFlags(PRUint32* aFlags);
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj); JSObject *obj);
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData) static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{ {

Просмотреть файл

@ -73,7 +73,7 @@ public:
* including nsIXPConnect, because we don't want to make everyone require * including nsIXPConnect, because we don't want to make everyone require
* JS and XPConnect. * JS and XPConnect.
*/ */
nsISupports* GetWrapper() nsISupports* GetWrapper() const
{ {
return reinterpret_cast<nsISupports*>(mWrapperPtrBits & ~kWrapperBitMask); return reinterpret_cast<nsISupports*>(mWrapperPtrBits & ~kWrapperBitMask);
} }