зеркало из https://github.com/mozilla/pjs.git
Fixing bug 406692. Speed up nsNodeSH::PreCreate(). r+sr=peterv@propagandism.org, a=jonas@sickin.cc
This commit is contained in:
Родитель
87964aa0e9
Коммит
2ebdd22dc4
|
@ -92,11 +92,12 @@ class nsIDocumentObserver;
|
|||
class nsBindingManager;
|
||||
class nsIDOMNodeList;
|
||||
class mozAutoSubtreeModified;
|
||||
struct JSObject;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0xc7f56e99, 0x5538, 0x4841, \
|
||||
{ 0x97, 0x39, 0x43, 0x6e, 0x6d, 0x26, 0x95, 0x12 } }
|
||||
{ 0xed21686d, 0x4e2f, 0x41f5, \
|
||||
{ 0x94, 0xaa, 0xcc, 0x1f, 0xbd, 0xfa, 0x1f, 0x84 } }
|
||||
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
|
@ -120,7 +121,8 @@ public:
|
|||
mNodeInfoManager(nsnull),
|
||||
mCompatMode(eCompatibility_FullStandards),
|
||||
mIsInitialDocumentInWindow(PR_FALSE),
|
||||
mPartID(0)
|
||||
mPartID(0),
|
||||
mJSObject(nsnull)
|
||||
{
|
||||
mParentPtrBits |= PARENT_BIT_INDOCUMENT;
|
||||
}
|
||||
|
@ -895,6 +897,16 @@ public:
|
|||
return mLoadedAsData;
|
||||
}
|
||||
|
||||
JSObject* GetJSObject() const
|
||||
{
|
||||
return mJSObject;
|
||||
}
|
||||
|
||||
void SetJSObject(JSObject *aJSObject)
|
||||
{
|
||||
mJSObject = aJSObject;
|
||||
}
|
||||
|
||||
protected:
|
||||
~nsIDocument()
|
||||
{
|
||||
|
@ -983,6 +995,12 @@ protected:
|
|||
|
||||
nsCOMArray<nsINode> mSubtreeModifiedTargets;
|
||||
PRUint32 mSubtreeModifiedDepth;
|
||||
|
||||
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)
|
||||
|
|
|
@ -492,7 +492,8 @@ static const char kDOMStringBundleURL[] =
|
|||
nsIXPCScriptable::WANT_ADDPROPERTY | \
|
||||
nsIXPCScriptable::WANT_DELPROPERTY | \
|
||||
nsIXPCScriptable::WANT_GETPROPERTY | \
|
||||
nsIXPCScriptable::WANT_POSTCREATE)
|
||||
nsIXPCScriptable::WANT_POSTCREATE | \
|
||||
nsIXPCScriptable::WANT_FINALIZE)
|
||||
|
||||
#define ARRAY_SCRIPTABLE_FLAGS \
|
||||
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
|
@ -6506,6 +6507,10 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
|
|||
// to wrap here? But that's not always reachable, let's use
|
||||
// globalObj for now...
|
||||
|
||||
if (native_parent == doc && (*parentObj = doc->GetJSObject())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
jsval v;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = WrapNative(cx, globalObj, native_parent,
|
||||
|
@ -7536,9 +7541,6 @@ NS_IMETHODIMP
|
|||
nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsresult rv = nsNodeSH::PostCreate(wrapper, cx, obj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If this is the current document for the window that's the script global
|
||||
// object of this document, then define this document object on the window.
|
||||
// That will make sure that the document is referenced (via window.document)
|
||||
|
@ -7548,6 +7550,13 @@ nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(sgo);
|
||||
if (!win) {
|
||||
|
@ -7587,6 +7596,20 @@ nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
|||
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 NS_OK;
|
||||
}
|
||||
|
||||
// HTMLDocument helper
|
||||
|
||||
// static
|
||||
|
|
|
@ -798,6 +798,8 @@ public:
|
|||
NS_IMETHOD GetFlags(PRUint32* aFlags);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче