зеркало из https://github.com/mozilla/pjs.git
Listen for document unload and kill the autocomplete popup if it's open. Bug 257354, r+sr=ben.
This commit is contained in:
Родитель
3e2c19c971
Коммит
927a069251
|
@ -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<nsIDOMEventTarget> target;
|
||||
aLoadEvent->GetTarget(getter_AddRefs(target));
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> eventDoc = do_QueryInterface(target);
|
||||
nsCOMPtr<nsIDOMDocument> 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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче