Bug 565633 - Inline nsIDocument::GetScriptHandlingObject, r=sicking

This commit is contained in:
Olli Pettay 2010-05-26 17:36:47 +03:00
parent 4eb311f30c
commit 7a25f9c457
3 changed files with 25 additions and 19 deletions

View File

@ -62,6 +62,7 @@
#ifdef MOZ_SMIL
#include "nsSMILAnimationController.h"
#endif // MOZ_SMIL
#include "nsIScriptGlobalObject.h"
class nsIContent;
class nsPresContext;
@ -72,7 +73,6 @@ class nsIStyleSheet;
class nsIStyleRule;
class nsCSSStyleSheet;
class nsIViewManager;
class nsIScriptGlobalObject;
class nsIDOMEvent;
class nsIDOMEventTarget;
class nsIDeviceContext;
@ -116,8 +116,8 @@ class Element;
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0xeb847679, 0x3b48, 0x411c, \
{ 0xa9, 0xb8, 0x8a, 0xdc, 0xdb, 0xc6, 0x47, 0xb8 } }
{ 0xdf6c0752, 0xe780, 0x4576, \
{ 0x95, 0x3c, 0x7e, 0xf1, 0xde, 0x9f, 0xd7, 0xf0 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -629,8 +629,13 @@ public:
* for event/script handling. Do not process any events/script if the method
* returns null, but aHasHadScriptHandlingObject is true.
*/
virtual nsIScriptGlobalObject*
GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const = 0;
nsIScriptGlobalObject*
GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const
{
aHasHadScriptHandlingObject = mHasHadScriptHandlingObject;
return mScriptGlobalObject ? mScriptGlobalObject.get() :
GetScriptHandlingObjectInternal();
}
virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) = 0;
/**
@ -1384,6 +1389,9 @@ protected:
// Never ever call this. Only call GetInnerWindow!
virtual nsPIDOMWindow *GetInnerWindowInternal() = 0;
// Never ever call this. Only call GetScriptHandlingObject!
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const = 0;
/**
* These methods should be called before and after dispatching
* a mutation event.
@ -1488,6 +1496,14 @@ protected:
// True while this document is being cloned to a static document.
PRPackedBool mCreatingStaticClone;
// True if document has ever had script handling object.
PRPackedBool mHasHadScriptHandlingObject;
// The document's script global object, the object from which the
// document can get its script context and scope. This is the
// *inner* window object.
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
// If mIsStaticDocument is true, mOriginalDocument points to the original
// document.
nsCOMPtr<nsIDocument> mOriginalDocument;

View File

@ -3682,12 +3682,10 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
}
nsIScriptGlobalObject*
nsDocument::GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const
nsDocument::GetScriptHandlingObjectInternal() const
{
aHasHadScriptHandlingObject = mHasHadScriptHandlingObject;
if (mScriptGlobalObject) {
return mScriptGlobalObject;
}
NS_ASSERTION(!mScriptGlobalObject,
"Do not call this when mScriptGlobalObject is set!");
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject);

View File

@ -644,8 +644,6 @@ public:
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const;
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
virtual nsIScriptGlobalObject*
GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const;
virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject);
virtual nsIScriptGlobalObject* GetScopeObject();
@ -1011,6 +1009,7 @@ protected:
virtual nsPIDOMWindow *GetWindowInternal();
virtual nsPIDOMWindow *GetInnerWindowInternal();
virtual nsIScriptGlobalObject* GetScriptHandlingObjectInternal() const;
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
NS_OBSERVER_ARRAY_NOTIFY_OBSERVERS(mObservers, nsIDocumentObserver, \
@ -1050,11 +1049,6 @@ protected:
// Array of observers
nsTObserverArray<nsIDocumentObserver*> mObservers;
// The document's script global object, the object from which the
// document can get its script context and scope. This is the
// *inner* window object.
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
// If document is created for example using
// document.implementation.createDocument(...), mScriptObject points to
// the script global object of the original document.
@ -1085,8 +1079,6 @@ protected:
PRPackedBool mIsGoingAway:1;
// True if the document is being destroyed.
PRPackedBool mInDestructor:1;
// True if document has ever had script handling object.
PRPackedBool mHasHadScriptHandlingObject:1;
// True if this document has ever had an HTML or SVG <title> element
// bound to it