Close the autocomplete popup if a context menu is opened (bug 296526), patch by martijn, r=me

git-svn-id: svn://10.0.0.236/trunk@200345 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bryner%brianryner.com
2006-06-19 19:55:33 +00:00
parent 5822a8453a
commit 268c29ba39
3 changed files with 34 additions and 9 deletions

View File

@@ -86,6 +86,7 @@ NS_INTERFACE_MAP_BEGIN(nsFormFillController)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMLoadListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMContextMenuListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFormFillController)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMFocusListener)
NS_INTERFACE_MAP_END
@@ -220,7 +221,7 @@ nsFormFillController::SetPopupOpen(PRBool aPopupOpen)
} else
mFocusedPopup->ClosePopup();
}
return NS_OK;
}
@@ -875,6 +876,14 @@ nsFormFillController::Error(nsIDOMEvent *aLoadEvent)
return NS_OK;
}
NS_IMETHODIMP
nsFormFillController::ContextMenu(nsIDOMEvent* aContextMenuEvent)
{
if (mFocusedPopup)
mFocusedPopup->ClosePopup();
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//// nsFormFillController
@@ -894,9 +903,9 @@ nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow)
if (!target)
return;
target->AddEventListener(NS_LITERAL_STRING("focus"),
NS_STATIC_CAST(nsIDOMFocusListener *, this),
PR_TRUE);
target->AddEventListener(NS_LITERAL_STRING("focus"),
NS_STATIC_CAST(nsIDOMFocusListener *, this),
PR_TRUE);
target->AddEventListener(NS_LITERAL_STRING("blur"),
NS_STATIC_CAST(nsIDOMFocusListener *, this),
@@ -925,6 +934,10 @@ nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow)
target->AddEventListener(NS_LITERAL_STRING("compositionend"),
NS_STATIC_CAST(nsIDOMCompositionListener *, this),
PR_TRUE);
target->AddEventListener(NS_LITERAL_STRING("contextmenu"),
NS_STATIC_CAST(nsIDOMContextMenuListener *, this),
PR_TRUE);
}
void
@@ -946,8 +959,8 @@ nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow)
return;
target->RemoveEventListener(NS_LITERAL_STRING("focus"),
NS_STATIC_CAST(nsIDOMFocusListener *, this),
PR_TRUE);
NS_STATIC_CAST(nsIDOMFocusListener *, this),
PR_TRUE);
target->RemoveEventListener(NS_LITERAL_STRING("blur"),
NS_STATIC_CAST(nsIDOMFocusListener *, this),
@@ -976,6 +989,10 @@ nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow)
target->RemoveEventListener(NS_LITERAL_STRING("compositionend"),
NS_STATIC_CAST(nsIDOMCompositionListener *, this),
PR_TRUE);
target->RemoveEventListener(NS_LITERAL_STRING("contextmenu"),
NS_STATIC_CAST(nsIDOMContextMenuListener *, this),
PR_TRUE);
}
void
@@ -983,7 +1000,7 @@ nsFormFillController::AddKeyListener(nsIDOMHTMLInputElement *aInput)
{
if (!aInput)
return;
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aInput);
target->AddEventListener(NS_LITERAL_STRING("keypress"),

View File

@@ -51,6 +51,7 @@
#include "nsIDOMFormListener.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMLoadListener.h"
#include "nsIDOMContextMenuListener.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
#include "nsIDocShell.h"
@@ -67,7 +68,8 @@ class nsFormFillController : public nsIFormFillController,
public nsIDOMCompositionListener,
public nsIDOMFormListener,
public nsIDOMMouseListener,
public nsIDOMLoadListener
public nsIDOMLoadListener,
public nsIDOMContextMenuListener
{
public:
NS_DECL_ISUPPORTS
@@ -114,6 +116,9 @@ public:
NS_IMETHOD Abort(nsIDOMEvent *aLoadEvent);
NS_IMETHOD Error(nsIDOMEvent *aLoadEvent);
// nsIDOMContextMenuListener
NS_IMETHOD ContextMenu(nsIDOMEvent* aContextMenuEvent);
nsFormFillController();
virtual ~nsFormFillController();

View File

@@ -516,7 +516,10 @@
<handler event="blur" phase="capturing"
action="if (!this._dontBlur) this.detachController();"/>
<handler event="contextmenu" phase="capturing"
action="this.closePopup();"/>
</handlers>
</binding>