зеркало из https://github.com/mozilla/pjs.git
Bug 393762, Bug 393761 and Bug 382636, r=jst, sr=peterv
This commit is contained in:
Родитель
971e32b489
Коммит
dc59d80cf7
|
@ -906,8 +906,7 @@ public:
|
|||
nsIDOMDocumentFragment** aReturn);
|
||||
|
||||
/**
|
||||
* Creates a new XML document, setting the document's container to be the
|
||||
* docshell of whatever script is on the JSContext stack.
|
||||
* Creates a new XML document, which is marked to be loaded as data.
|
||||
*
|
||||
* @param aNamespaceURI Namespace for the root element to create and insert in
|
||||
* the document. Only used if aQualifiedName is not
|
||||
|
@ -919,6 +918,8 @@ public:
|
|||
* @param aDocumentURI URI of the document. Must not be null.
|
||||
* @param aBaseURI Base URI of the document. Must not be null.
|
||||
* @param aPrincipal Prinicpal of the document. Must not be null.
|
||||
* @param aScriptObject The object from which the context for event handling
|
||||
* can be got.
|
||||
* @param aResult [out] The document that was created.
|
||||
*/
|
||||
static nsresult CreateDocument(const nsAString& aNamespaceURI,
|
||||
|
@ -927,6 +928,7 @@ public:
|
|||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsIScriptGlobalObject* aScriptObject,
|
||||
nsIDOMDocument** aResult);
|
||||
|
||||
/**
|
||||
|
@ -1172,10 +1174,11 @@ private:
|
|||
class nsCxPusher
|
||||
{
|
||||
public:
|
||||
nsCxPusher(nsISupports *aCurrentTarget);
|
||||
~nsCxPusher();
|
||||
nsCxPusher();
|
||||
~nsCxPusher(); // Calls Pop();
|
||||
|
||||
void Push(nsISupports *aCurrentTarget);
|
||||
// Returns PR_FALSE if something erroneous happened.
|
||||
PRBool Push(nsISupports *aCurrentTarget);
|
||||
void Pop();
|
||||
|
||||
private:
|
||||
|
|
|
@ -41,6 +41,7 @@ interface nsIInputStream;
|
|||
interface nsIDOMDocument;
|
||||
interface nsIURI;
|
||||
interface nsIPrincipal;
|
||||
interface nsIScriptGlobalObject;
|
||||
|
||||
/**
|
||||
* The nsIDOMParser interface is a non-SAX interface that can be used
|
||||
|
@ -50,7 +51,7 @@ interface nsIPrincipal;
|
|||
* parsing with the XMLHttpRequest interface, which can be used for
|
||||
* asynchronous (callback-based) loading.
|
||||
*/
|
||||
[scriptable, uuid(5db52912-cdee-46d2-9166-01436c3f9e73)]
|
||||
[scriptable, uuid(5677f36e-1842-4c6f-a39c-2e5576ab8b40)]
|
||||
interface nsIDOMParser : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -114,10 +115,13 @@ interface nsIDOMParser : nsISupports
|
|||
* URI must be non-null.
|
||||
* @param baseURI The baseURI to use for the documents we create.
|
||||
* If null, the documentURI will be used.
|
||||
* @param scriptObject The object from which the context for event handling
|
||||
* can be got.
|
||||
*/
|
||||
[noscript] void init(in nsIPrincipal principal,
|
||||
in nsIURI documentURI,
|
||||
in nsIURI baseURI);
|
||||
in nsIURI baseURI,
|
||||
in nsIScriptGlobalObject scriptObject);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,8 +96,8 @@ class mozAutoSubtreeModified;
|
|||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x9a26d0aa, 0x37d2, 0x4313, \
|
||||
{ 0x9e, 0x53, 0x16, 0xd1, 0xa4, 0x67, 0xb3, 0x5b } }
|
||||
{ 0xc7f56e99, 0x5538, 0x4841, \
|
||||
{ 0x97, 0x39, 0x43, 0x6e, 0x6d, 0x26, 0x95, 0x12 } }
|
||||
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
|
@ -508,6 +508,19 @@ public:
|
|||
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0;
|
||||
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0;
|
||||
|
||||
/**
|
||||
* Get/set the object from which the context for the event/script handling can
|
||||
* be got. Normally GetScriptHandlingObject() returns the same object as
|
||||
* GetScriptGlobalObject(), but if the document is loaded as data,
|
||||
* non-null may be returned, even if GetScriptGlobalObject() returns null.
|
||||
* aHasHadScriptHandlingObject is set PR_TRUE if document has had the object
|
||||
* 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;
|
||||
virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject) = 0;
|
||||
|
||||
/**
|
||||
* Get the object that is used as the scope for all of the content
|
||||
* wrappers whose owner document is this document. Unlike the script global
|
||||
|
@ -1085,7 +1098,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal);
|
||||
nsIPrincipal* aPrincipal,
|
||||
PRBool aLoadedAsData);
|
||||
nsresult
|
||||
NS_NewPluginDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
|
|
|
@ -2376,12 +2376,9 @@ nsContentUtils::GetEventArgNames(PRInt32 aNameSpaceID,
|
|||
}
|
||||
}
|
||||
|
||||
nsCxPusher::nsCxPusher(nsISupports *aCurrentTarget)
|
||||
nsCxPusher::nsCxPusher()
|
||||
: mScriptIsRunning(PR_FALSE)
|
||||
{
|
||||
if (aCurrentTarget) {
|
||||
Push(aCurrentTarget);
|
||||
}
|
||||
}
|
||||
|
||||
nsCxPusher::~nsCxPusher()
|
||||
|
@ -2422,32 +2419,29 @@ IsContextOnStack(nsIJSContextStack *aStack, JSContext *aContext)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
PRBool
|
||||
nsCxPusher::Push(nsISupports *aCurrentTarget)
|
||||
{
|
||||
if (mScx) {
|
||||
NS_ERROR("Whaaa! No double pushing with nsCxPusher::Push()!");
|
||||
|
||||
return;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aCurrentTarget));
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(aCurrentTarget));
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
|
||||
if (content) {
|
||||
document = content->GetOwnerDoc();
|
||||
}
|
||||
|
||||
if (!document) {
|
||||
document = do_QueryInterface(aCurrentTarget);
|
||||
}
|
||||
|
||||
if (document) {
|
||||
sgo = document->GetScriptGlobalObject();
|
||||
}
|
||||
|
||||
if (!document && !sgo) {
|
||||
if (node) {
|
||||
document = node->GetOwnerDoc();
|
||||
if (document) {
|
||||
PRBool hasHadScriptObject = PR_TRUE;
|
||||
sgo = document->GetScriptHandlingObject(hasHadScriptObject);
|
||||
// It is bad if the document doesn't have event handling context,
|
||||
// but it used to have one.
|
||||
NS_ENSURE_TRUE(sgo || !hasHadScriptObject, PR_FALSE);
|
||||
}
|
||||
} else {
|
||||
sgo = do_QueryInterface(aCurrentTarget);
|
||||
}
|
||||
|
||||
|
@ -2459,6 +2453,8 @@ nsCxPusher::Push(nsISupports *aCurrentTarget)
|
|||
if (mScx) {
|
||||
cx = (JSContext *)mScx->GetNativeContext();
|
||||
}
|
||||
// Bad, no JSContext from script global object!
|
||||
NS_ENSURE_TRUE(cx, PR_FALSE);
|
||||
}
|
||||
|
||||
if (cx) {
|
||||
|
@ -2483,6 +2479,7 @@ nsCxPusher::Push(nsISupports *aCurrentTarget)
|
|||
|
||||
mScx = nsnull;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3351,25 +3348,16 @@ nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
|
|||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsIScriptGlobalObject* aEventObject,
|
||||
nsIDOMDocument** aResult)
|
||||
{
|
||||
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
|
||||
aDoctype, aDocumentURI, aBaseURI, aPrincipal);
|
||||
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
|
||||
PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIDocShell *docShell = GetDocShellFromCaller();
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsPresContext> presContext;
|
||||
docShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
nsCOMPtr<nsISupports> container = presContext->GetContainer();
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
|
||||
if (document) {
|
||||
document->SetContainer(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
|
||||
document->SetScriptHandlingObject(aEventObject);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,6 +190,8 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
|||
(nsCRT::strcmp(contentType, "application/xhtml+xml") != 0))
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
|
||||
do_QueryReferent(mScriptHandlingObject);
|
||||
nsresult rv;
|
||||
if (!mPrincipal) {
|
||||
NS_ENSURE_TRUE(!mAttemptedInit, NS_ERROR_NOT_INITIALIZED);
|
||||
|
@ -199,7 +201,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
|||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = Init(prin, nsnull, nsnull);
|
||||
rv = Init(prin, nsnull, nsnull, scriptHandlingObject);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -215,10 +217,11 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
|||
|
||||
stream = bufferedStream;
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
|
||||
mDocumentURI, mBaseURI, mPrincipal,
|
||||
scriptHandlingObject,
|
||||
getter_AddRefs(domDocument));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -313,7 +316,7 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
|
||||
nsIURI* baseURI)
|
||||
nsIURI* baseURI, nsIScriptGlobalObject* aScriptObject)
|
||||
{
|
||||
NS_ENSURE_STATE(!mAttemptedInit);
|
||||
mAttemptedInit = PR_TRUE;
|
||||
|
@ -328,6 +331,7 @@ nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
|
|||
}
|
||||
}
|
||||
|
||||
mScriptHandlingObject = do_GetWeakReference(aScriptObject);
|
||||
mPrincipal = principal;
|
||||
if (!mPrincipal) {
|
||||
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
|
||||
|
@ -470,7 +474,9 @@ nsDOMParser::Initialize(JSContext *cx, JSObject* obj,
|
|||
documentURI = doc->GetDocumentURI();
|
||||
}
|
||||
|
||||
return Init(prin, documentURI, baseURI);
|
||||
nsIScriptContext* scriptContext = GetScriptContextFromJSContext(cx);
|
||||
return Init(prin, documentURI, baseURI,
|
||||
scriptContext ? scriptContext->GetGlobalObject() : nsnull);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -506,5 +512,7 @@ nsDOMParser::Init()
|
|||
getter_AddRefs(documentURI), getter_AddRefs(baseURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return Init(prin, documentURI, baseURI);
|
||||
nsIScriptContext* scriptContext = GetScriptContextFromJSContext(cx);
|
||||
return Init(prin, documentURI, baseURI,
|
||||
scriptContext ? scriptContext->GetGlobalObject() : nsnull);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ private:
|
|||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsWeakPtr mScriptHandlingObject;
|
||||
|
||||
PRPackedBool mLoopingForSyncLoad;
|
||||
PRPackedBool mAttemptedInit;
|
||||
|
|
|
@ -609,7 +609,8 @@ class nsDOMImplementation : public nsIDOMDOMImplementation,
|
|||
public nsIPrivateDOMImplementation
|
||||
{
|
||||
public:
|
||||
nsDOMImplementation(nsIURI* aDocumentURI,
|
||||
nsDOMImplementation(nsIScriptGlobalObject* aScriptObject,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal);
|
||||
virtual ~nsDOMImplementation();
|
||||
|
@ -624,6 +625,7 @@ public:
|
|||
nsIPrincipal* aPrincipal);
|
||||
|
||||
protected:
|
||||
nsWeakPtr mScriptObject;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
@ -633,7 +635,7 @@ protected:
|
|||
nsresult
|
||||
NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult)
|
||||
{
|
||||
*aInstancePtrResult = new nsDOMImplementation(nsnull, nsnull, nsnull);
|
||||
*aInstancePtrResult = new nsDOMImplementation(nsnull, nsnull, nsnull, nsnull);
|
||||
if (!*aInstancePtrResult) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -643,10 +645,12 @@ NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMImplementation::nsDOMImplementation(nsIURI* aDocumentURI,
|
||||
nsDOMImplementation::nsDOMImplementation(nsIScriptGlobalObject* aScriptObject,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal)
|
||||
: mDocumentURI(aDocumentURI),
|
||||
: mScriptObject(do_GetWeakReference(aScriptObject)),
|
||||
mDocumentURI(aDocumentURI),
|
||||
mBaseURI(aBaseURI),
|
||||
mPrincipal(aPrincipal)
|
||||
{
|
||||
|
@ -735,9 +739,12 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
|
||||
do_QueryReferent(mScriptObject);
|
||||
|
||||
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
|
||||
mDocumentURI, mBaseURI, mPrincipal,
|
||||
aReturn);
|
||||
scriptHandlingObject, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2601,12 +2608,37 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
|
|||
mScriptGlobalObject = aScriptGlobalObject;
|
||||
|
||||
if (aScriptGlobalObject) {
|
||||
mHasHadScriptHandlingObject = PR_TRUE;
|
||||
// Go back to using the docshell for the layout history state
|
||||
mLayoutHistoryState = nsnull;
|
||||
mScopeObject = do_GetWeakReference(aScriptGlobalObject);
|
||||
}
|
||||
}
|
||||
|
||||
nsIScriptGlobalObject*
|
||||
nsDocument::GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const
|
||||
{
|
||||
aHasHadScriptHandlingObject = mHasHadScriptHandlingObject;
|
||||
if (mScriptGlobalObject) {
|
||||
return mScriptGlobalObject;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
|
||||
do_QueryReferent(mScriptObject);
|
||||
return scriptHandlingObject;
|
||||
}
|
||||
void
|
||||
nsDocument::SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject)
|
||||
{
|
||||
NS_ASSERTION(!mScriptGlobalObject ||
|
||||
mScriptGlobalObject == aScriptObject,
|
||||
"Wrong script object!");
|
||||
mScriptObject = do_GetWeakReference(aScriptObject);
|
||||
if (aScriptObject) {
|
||||
mHasHadScriptHandlingObject = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsPIDOMWindow *
|
||||
nsDocument::GetWindow()
|
||||
{
|
||||
|
@ -2959,8 +2991,12 @@ nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), "about:blank");
|
||||
NS_ENSURE_TRUE(uri, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aImplementation = new nsDOMImplementation(uri, uri, NodePrincipal());
|
||||
PRBool hasHadScriptObject = PR_TRUE;
|
||||
nsIScriptGlobalObject* scriptObject =
|
||||
GetScriptHandlingObject(hasHadScriptObject);
|
||||
NS_ENSURE_STATE(scriptObject || !hasHadScriptObject);
|
||||
*aImplementation = new nsDOMImplementation(scriptObject, uri, uri,
|
||||
NodePrincipal());
|
||||
if (!*aImplementation) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -433,6 +433,10 @@ public:
|
|||
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const;
|
||||
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
|
||||
|
||||
virtual nsIScriptGlobalObject*
|
||||
GetScriptHandlingObject(PRBool& aHasHadScriptHandlingObject) const;
|
||||
virtual void SetScriptHandlingObject(nsIScriptGlobalObject* aScriptObject);
|
||||
|
||||
virtual nsIScriptGlobalObject* GetScopeObject();
|
||||
|
||||
/**
|
||||
|
@ -744,6 +748,11 @@ protected:
|
|||
// *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.
|
||||
nsWeakPtr mScriptObject;
|
||||
|
||||
// Weak reference to the scope object (aka the script global object)
|
||||
// that, unlike mScriptGlobalObject, is never unset once set. This
|
||||
// is a weak reference to avoid leaks due to circular references.
|
||||
|
@ -763,6 +772,8 @@ protected:
|
|||
PRPackedBool mInDestructor:1;
|
||||
// True if the document "page" is not hidden
|
||||
PRPackedBool mVisible:1;
|
||||
// True if document has ever had script handling object.
|
||||
PRPackedBool mHasHadScriptHandlingObject:1;
|
||||
|
||||
PRUint8 mXMLDeclarationBits;
|
||||
|
||||
|
|
|
@ -1550,8 +1550,10 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||
|
||||
// Create an empty document from it
|
||||
const nsAString& emptyStr = EmptyString();
|
||||
nsIScriptGlobalObject* global = mScriptContext ?
|
||||
mScriptContext->GetGlobalObject() : nsnull;
|
||||
nsresult rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull, uri,
|
||||
uri, mPrincipal,
|
||||
uri, mPrincipal, global,
|
||||
getter_AddRefs(mDocument));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -1087,11 +1087,10 @@ nsEventListenerManager::HandleEventSubType(nsListenerStruct* aListenerStruct,
|
|||
}
|
||||
}
|
||||
|
||||
// nsCxPusher will automatically push and pop the current cx onto the
|
||||
// nsCxPusher will push and pop (automatically) the current cx onto the
|
||||
// context stack
|
||||
nsCxPusher pusher(aCurrentTarget);
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsCxPusher pusher;
|
||||
if (NS_SUCCEEDED(result) && pusher.Push(aCurrentTarget)) {
|
||||
// nsIDOMEvent::currentTarget is set in nsEventDispatcher.
|
||||
result = aListener->HandleEvent(aDOMEvent);
|
||||
}
|
||||
|
|
|
@ -4342,10 +4342,12 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
|||
nsCOMPtr<nsIContent> temp = gLastFocusedContent;
|
||||
NS_RELEASE(gLastFocusedContent); // nulls out gLastFocusedContent
|
||||
|
||||
nsCxPusher pusher(temp);
|
||||
nsEventDispatcher::Dispatch(temp, oldPresContext, &event, nsnull,
|
||||
&status);
|
||||
pusher.Pop();
|
||||
nsCxPusher pusher;
|
||||
if (pusher.Push(temp)) {
|
||||
nsEventDispatcher::Dispatch(temp, oldPresContext, &event, nsnull,
|
||||
&status);
|
||||
pusher.Pop();
|
||||
}
|
||||
|
||||
focusAfterBlur = mCurrentFocus;
|
||||
if (!previousFocus || previousFocus == focusAfterBlur)
|
||||
|
@ -4403,10 +4405,12 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
|||
NS_RELEASE(gLastFocusedDocument);
|
||||
gLastFocusedDocument = nsnull;
|
||||
|
||||
nsCxPusher pusher(temp);
|
||||
nsEventDispatcher::Dispatch(temp, gLastFocusedPresContext, &event, nsnull,
|
||||
&status);
|
||||
pusher.Pop();
|
||||
nsCxPusher pusher;
|
||||
if (pusher.Push(temp)) {
|
||||
nsEventDispatcher::Dispatch(temp, gLastFocusedPresContext, &event,
|
||||
nsnull, &status);
|
||||
pusher.Pop();
|
||||
}
|
||||
|
||||
if (previousFocus && mCurrentFocus != previousFocus) {
|
||||
// The document's blur handler focused something else.
|
||||
|
@ -4417,15 +4421,16 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
pusher.Push(window);
|
||||
nsEventDispatcher::Dispatch(window, gLastFocusedPresContext, &event,
|
||||
nsnull, &status);
|
||||
if (pusher.Push(window)) {
|
||||
nsEventDispatcher::Dispatch(window, gLastFocusedPresContext, &event,
|
||||
nsnull, &status);
|
||||
|
||||
if (previousFocus && mCurrentFocus != previousFocus) {
|
||||
// The window's blur handler focused something else.
|
||||
// Abort firing any additional blur or focus events.
|
||||
EnsureFocusSynchronization();
|
||||
return NS_OK;
|
||||
if (previousFocus && mCurrentFocus != previousFocus) {
|
||||
// The window's blur handler focused something else.
|
||||
// Abort firing any additional blur or focus events.
|
||||
EnsureFocusSynchronization();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4490,11 +4495,11 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
|||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
|
||||
if (nsnull != mPresContext) {
|
||||
nsCxPusher pusher(aContent);
|
||||
nsEventDispatcher::Dispatch(aContent, mPresContext, &event, nsnull,
|
||||
&status);
|
||||
nsAutoString name;
|
||||
aContent->Tag()->ToString(name);
|
||||
nsCxPusher pusher;
|
||||
if (pusher.Push(aContent)) {
|
||||
nsEventDispatcher::Dispatch(aContent, mPresContext, &event, nsnull,
|
||||
&status);
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString tabIndex;
|
||||
|
@ -4515,9 +4520,11 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
|||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
|
||||
if (nsnull != mPresContext && mDocument) {
|
||||
nsCxPusher pusher(mDocument);
|
||||
nsEventDispatcher::Dispatch(mDocument, mPresContext, &event, nsnull,
|
||||
&status);
|
||||
nsCxPusher pusher;
|
||||
if (pusher.Push(mDocument)) {
|
||||
nsEventDispatcher::Dispatch(mDocument, mPresContext, &event, nsnull,
|
||||
&status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -339,7 +339,8 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
|||
// Now call the method
|
||||
|
||||
// Use nsCxPusher to make sure we call ScriptEvaluated when we're done.
|
||||
nsCxPusher pusher(aBoundElement);
|
||||
nsCxPusher pusher;
|
||||
NS_ENSURE_STATE(pusher.Push(aBoundElement));
|
||||
|
||||
// Check whether it's OK to call the method.
|
||||
rv = nsContentUtils::GetSecurityManager()->CheckFunctionAccess(cx, method,
|
||||
|
|
|
@ -105,7 +105,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal)
|
||||
nsIPrincipal* aPrincipal,
|
||||
PRBool aLoadedAsData)
|
||||
{
|
||||
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
|
||||
// since at least one caller (XMLHttpRequest) doesn't have decent args to
|
||||
|
@ -125,6 +126,7 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
|||
return rv;
|
||||
}
|
||||
|
||||
doc->SetLoadedAsData(aLoadedAsData);
|
||||
doc->nsDocument::SetDocumentURI(aDocumentURI);
|
||||
// Must set the principal first, since SetBaseURI checks it.
|
||||
doc->SetPrincipal(aPrincipal);
|
||||
|
@ -629,19 +631,8 @@ nsXMLDocument::EndLoad()
|
|||
// document was loaded as pure data without any presentation
|
||||
// attached to it.
|
||||
nsEvent event(PR_TRUE, NS_LOAD);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsIScriptGlobalObject* sgo = nsnull;
|
||||
nsCOMPtr<nsIScriptGlobalObjectOwner> container =
|
||||
do_QueryReferent(mDocumentContainer);
|
||||
if (container) {
|
||||
sgo = container->GetScriptGlobalObject();
|
||||
}
|
||||
|
||||
nsCxPusher pusher(sgo);
|
||||
|
||||
nsEventDispatcher::Dispatch(static_cast<nsIDocument*>(this), nsnull,
|
||||
&event, nsnull, &status);
|
||||
&event);
|
||||
}
|
||||
nsDocument::EndLoad();
|
||||
}
|
||||
|
@ -691,12 +682,19 @@ nsXMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
|||
NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
|
||||
"Can't import this document into another document!");
|
||||
|
||||
PRBool hasHadScriptObject = PR_TRUE;
|
||||
nsIScriptGlobalObject* scriptObject =
|
||||
GetScriptHandlingObject(hasHadScriptObject);
|
||||
NS_ENSURE_STATE(scriptObject || !hasHadScriptObject);
|
||||
nsCOMPtr<nsIDOMDocument> newDoc;
|
||||
nsresult rv = NS_NewDOMDocument(getter_AddRefs(newDoc), EmptyString(),
|
||||
EmptyString(), nsnull,
|
||||
nsIDocument::GetDocumentURI(),
|
||||
nsIDocument::GetBaseURI(), NodePrincipal());
|
||||
nsIDocument::GetBaseURI(), NodePrincipal(),
|
||||
PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(newDoc);
|
||||
document->SetScriptHandlingObject(scriptObject);
|
||||
|
||||
return CallQueryInterface(newDoc, aResult);
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ public:
|
|||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsXMLDocument, nsDocument)
|
||||
|
||||
void SetLoadedAsData(PRBool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
|
||||
protected:
|
||||
virtual nsresult GetLoadGroup(nsILoadGroup **aLoadGroup);
|
||||
|
||||
|
|
|
@ -165,11 +165,16 @@ nsXULTemplateQueryProcessorXML::GetDatasource(nsIArray* aDataSources,
|
|||
if (!uri)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRBool hasHadScriptObject = PR_TRUE;
|
||||
nsIScriptGlobalObject* scriptObject =
|
||||
doc->GetScriptHandlingObject(hasHadScriptObject);
|
||||
NS_ENSURE_STATE(scriptObject || !hasHadScriptObject);
|
||||
nsAutoString emptyStr;
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nsnull,
|
||||
docurl, doc->GetBaseURI(),
|
||||
docPrincipal,
|
||||
scriptObject,
|
||||
getter_AddRefs(domDocument));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -242,9 +242,11 @@ nsTextBoxFrame::UpdateAccesskey(nsWeakFrame& aWeakThis)
|
|||
// may not be the right one. Pushing the context of mContent so that
|
||||
// if nsIDOMXULLabelElement is implemented in XBL, we don't get a
|
||||
// security exception.
|
||||
nsCxPusher cx(mContent);
|
||||
labelElement->GetAccessKey(accesskey);
|
||||
NS_ENSURE_TRUE(aWeakThis.IsAlive(), PR_FALSE);
|
||||
nsCxPusher cx;
|
||||
if (cx.Push(mContent)) {
|
||||
labelElement->GetAccessKey(accesskey);
|
||||
NS_ENSURE_TRUE(aWeakThis.IsAlive(), PR_FALSE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accesskey);
|
||||
|
|
Загрузка…
Ссылка в новой задаче