diff --git a/toolkit/components/satchel/src/nsFormFillController.cpp b/toolkit/components/satchel/src/nsFormFillController.cpp index 6d00eefcb81..dfe47c72ffa 100644 --- a/toolkit/components/satchel/src/nsFormFillController.cpp +++ b/toolkit/components/satchel/src/nsFormFillController.cpp @@ -78,6 +78,7 @@ NS_INTERFACE_MAP_BEGIN(nsFormFillController) NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener) NS_INTERFACE_MAP_ENTRY(nsIDOMFormListener) NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener) + NS_INTERFACE_MAP_ENTRY(nsIDOMLoadListener) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFormFillController) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFocusListener) NS_INTERFACE_MAP_END @@ -758,6 +759,51 @@ nsFormFillController::MouseOut(nsIDOMEvent* aMouseEvent) return NS_OK; } +//////////////////////////////////////////////////////////////////////// +//// nsIDOMLoadListener + +NS_IMETHODIMP +nsFormFillController::Load(nsIDOMEvent *aLoadEvent) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsFormFillController::BeforeUnload(nsIDOMEvent *aLoadEvent) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsFormFillController::Unload(nsIDOMEvent *aLoadEvent) +{ + if (mFocusedInput) { + nsCOMPtr target; + aLoadEvent->GetTarget(getter_AddRefs(target)); + + nsCOMPtr eventDoc = do_QueryInterface(target); + nsCOMPtr inputDoc; + mFocusedInput->GetOwnerDocument(getter_AddRefs(inputDoc)); + + if (eventDoc == inputDoc) + StopControllingInput(); + } + + return NS_OK; +} + +NS_IMETHODIMP +nsFormFillController::Abort(nsIDOMEvent *aLoadEvent) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsFormFillController::Error(nsIDOMEvent *aLoadEvent) +{ + return NS_OK; +} + //////////////////////////////////////////////////////////////////////// //// nsFormFillController @@ -796,6 +842,10 @@ nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow) target->AddEventListener(NS_LITERAL_STRING("input"), NS_STATIC_CAST(nsIDOMFormListener *, this), PR_TRUE); + + target->AddEventListener(NS_LITERAL_STRING("unload"), + NS_STATIC_CAST(nsIDOMLoadListener *, this), + PR_TRUE); } void @@ -835,6 +885,10 @@ nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow) target->RemoveEventListener(NS_LITERAL_STRING("input"), NS_STATIC_CAST(nsIDOMFormListener *, this), PR_TRUE); + + target->RemoveEventListener(NS_LITERAL_STRING("unload"), + NS_STATIC_CAST(nsIDOMLoadListener *, this), + PR_TRUE); } void diff --git a/toolkit/components/satchel/src/nsFormFillController.h b/toolkit/components/satchel/src/nsFormFillController.h index c63c5914674..ea28ead3e7d 100644 --- a/toolkit/components/satchel/src/nsFormFillController.h +++ b/toolkit/components/satchel/src/nsFormFillController.h @@ -49,6 +49,7 @@ #include "nsIDOMKeyListener.h" #include "nsIDOMFormListener.h" #include "nsIDOMMouseListener.h" +#include "nsIDOMLoadListener.h" #include "nsCOMPtr.h" #include "nsISupportsArray.h" #include "nsIDocShell.h" @@ -62,7 +63,8 @@ class nsFormFillController : public nsIFormFillController, public nsIDOMFocusListener, public nsIDOMKeyListener, public nsIDOMFormListener, - public nsIDOMMouseListener + public nsIDOMMouseListener, + public nsIDOMLoadListener { public: NS_DECL_ISUPPORTS @@ -95,6 +97,13 @@ public: NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent); NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent); + // nsIDOMLoadListener + NS_IMETHOD Load(nsIDOMEvent *aLoadEvent); + NS_IMETHOD BeforeUnload(nsIDOMEvent *aLoadEvent); + NS_IMETHOD Unload(nsIDOMEvent *aLoadEvent); + NS_IMETHOD Abort(nsIDOMEvent *aLoadEvent); + NS_IMETHOD Error(nsIDOMEvent *aLoadEvent); + nsFormFillController(); virtual ~nsFormFillController();