Fix assorted issues with fastback, including adding progress listener notifications and introducing the PageHide and PageShow events. See bug 292971 for all of the details. r=darin, sr=bzbarsky, a=shaver.

git-svn-id: svn://10.0.0.236/trunk@174651 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bryner%brianryner.com
2005-06-15 23:52:46 +00:00
parent 5efdb69c74
commit 3274ca4c10
62 changed files with 791 additions and 443 deletions

View File

@@ -128,6 +128,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
#include "nsBindingManager.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIRequest.h"
#include "nsILink.h"
#include "nsICharsetAlias.h"
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
@@ -4909,3 +4910,73 @@ nsDocument::UnblockOnload()
}
}
}
void
nsDocument::OnPageShow(PRBool aPersisted)
{
if (aPersisted) {
// Send out notifications that our <link> elements are attached.
nsRefPtr<nsContentList> links = NS_GetContentList(this,
nsHTMLAtoms::link,
kNameSpaceID_Unknown,
mRootContent);
if (links) {
PRUint32 linkCount = links->Length(PR_TRUE);
for (PRUint32 i = 0; i < linkCount; ++i) {
nsCOMPtr<nsILink> link = do_QueryInterface(links->Item(i, PR_FALSE));
if (link) {
link->LinkAdded();
}
}
}
}
nsIPresShell *shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[0]);
if (shell && mScriptGlobalObject) {
nsPresContext *pc = shell->GetPresContext();
if (pc) {
nsPageTransitionEvent event(PR_TRUE, NS_PAGE_SHOW, aPersisted);
nsEventStatus status = nsEventStatus_eIgnore;
mScriptGlobalObject->HandleDOMEvent(pc, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
}
}
}
void
nsDocument::OnPageHide(PRBool aPersisted)
{
// Send out notifications that our <link> elements are detached,
// but only if this is not a full unload.
if (aPersisted) {
nsRefPtr<nsContentList> links = NS_GetContentList(this,
nsHTMLAtoms::link,
kNameSpaceID_Unknown,
mRootContent);
if (links) {
PRUint32 linkCount = links->Length(PR_TRUE);
for (PRUint32 i = 0; i < linkCount; ++i) {
nsCOMPtr<nsILink> link = do_QueryInterface(links->Item(i, PR_FALSE));
if (link) {
link->LinkRemoved();
}
}
}
}
// Now send out a PageHide event.
nsIPresShell *shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[0]);
if (shell && mScriptGlobalObject) {
nsPresContext *pc = shell->GetPresContext();
if (pc) {
nsPageTransitionEvent event(PR_TRUE, NS_PAGE_HIDE, aPersisted);
nsEventStatus status = nsEventStatus_eIgnore;
mScriptGlobalObject->HandleDOMEvent(pc, &event, nsnull,
NS_EVENT_FLAG_INIT, &status);
}
}
}

View File

@@ -440,6 +440,9 @@ public:
PRUint32 aFlags,
nsEventStatus* aEventStatus);
virtual void OnPageShow(PRBool aPersisted);
virtual void OnPageHide(PRBool aPersisted);
// nsIRadioGroupContainer
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
nsIRadioVisitor* aVisitor);

View File

@@ -120,7 +120,6 @@ public:
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
NS_IMETHOD Error(nsIDOMEvent* aEvent);
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
NS_DECL_NSICHANNELEVENTSINK
@@ -162,7 +161,6 @@ public:
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
NS_IMETHOD Error(nsIDOMEvent* aEvent);
NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
protected:
nsWeakPtr mParent;
@@ -251,18 +249,6 @@ txLoadListenerProxy::Error(nsIDOMEvent* aEvent)
return NS_OK;
}
NS_IMETHODIMP
txLoadListenerProxy::PageRestore(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIDOMLoadListener> listener = do_QueryReferent(mParent);
if (listener) {
return listener->PageRestore(aEvent);
}
return NS_OK;
}
class nsForceXMLListener : public nsIStreamListener
{
public:
@@ -526,12 +512,6 @@ nsSyncLoader::Error(nsIDOMEvent* aEvent)
return NS_OK;
}
NS_IMETHODIMP
nsSyncLoader::PageRestore(nsIDOMEvent* aEvent)
{
return NS_OK;
}
NS_IMETHODIMP
nsSyncLoader::OnChannelRedirect(nsIChannel *aOldChannel,
nsIChannel *aNewChannel,