From d75361a1a1ece1fbabde539b8d27408ff0670754 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Tue, 1 Nov 2005 15:38:55 +0000 Subject: [PATCH] Bug 314452 - In HandleEvent, verify that the type/URI of the plugin didn't change before calling instantiate - Revoke pending instantiate events when a new plugin is loading r+sr=bz git-svn-id: svn://10.0.0.236/trunk@183341 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/src/nsObjectLoadingContent.cpp | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/mozilla/content/base/src/nsObjectLoadingContent.cpp b/mozilla/content/base/src/nsObjectLoadingContent.cpp index 576aa3da96a..081a71d868e 100644 --- a/mozilla/content/base/src/nsObjectLoadingContent.cpp +++ b/mozilla/content/base/src/nsObjectLoadingContent.cpp @@ -127,21 +127,28 @@ nsAsyncInstantiateEvent::HandleEvent(PLEvent* event) event); nsObjectLoadingContent* con = NS_STATIC_CAST(nsObjectLoadingContent*, PL_GetEventOwner(event)); - // Make sure that we still have the right frame - if (con->GetFrame() == ev->mFrame) { + // Make sure that we still have the right frame (NOTE: we don't need to check + // the type here - GetFrame() only returns object frames, and that means we're + // a plugin) + // Also make sure that we still refer to the same data. + if (con->GetFrame() == ev->mFrame && + con->mURI == ev->mURI && + con->mContentType.Equals(ev->mContentType)) { if (LOG_ENABLED()) { nsCAutoString spec; if (ev->mURI) { ev->mURI->GetSpec(spec); } LOG(("OBJLC [%p]: Handling Instantiate event: Type=<%s> URI=%p<%s>\n", - con, ev->mContentType.get(), ev->mURI, spec.get())); + con, ev->mContentType.get(), ev->mURI.get(), spec.get())); } nsresult rv = con->Instantiate(ev->mContentType, ev->mURI); if (NS_FAILED(rv)) { con->Fallback(PR_TRUE); } + } else { + LOG(("OBJLC [%p]: Discarding event, data changed\n", con)); } return nsnull; } @@ -599,6 +606,16 @@ nsObjectLoadingContent::ObjectURIChanged(nsIURI* aURI, } } + // Need to revoke any potentially pending instantiate events + if (mType == eType_Plugin) { + nsCOMPtr eventQ; + NS_GetCurrentEventQ(getter_AddRefs(eventQ)); + if (eventQ) { + LOG(("OBJLC [%p]: Revoking events\n", this)); + eventQ->RevokeEvents(this); + } + } + AutoNotifier notifier(this, aNotify); mUserDisabled = mSuppressed = PR_FALSE;