Bug 187772 mouse wheel scrolling does not dismiss form auto complete history, results in floating autocomplete dropdown r=mconnor

This commit is contained in:
masayuki%d-toybox.com 2006-03-18 08:09:52 +00:00
Родитель 1d2adbe0ad
Коммит 79d8af6102
5 изменённых файлов: 112 добавлений и 3 удалений

Просмотреть файл

@ -21,6 +21,7 @@
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (Original Author)
* Dean Tessman <dean_tessman@hotmail.com>
* Masayuki Nakano <masayuki@d-toybox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -40,7 +41,7 @@
interface nsIAutoCompleteInput;
[scriptable, uuid(CF2ACA0C-4FB1-42e4-8A54-23E832CB2A98)]
[scriptable, uuid(8E62F092-DD82-4748-BAB3-8898C7C881A1)]
interface nsIAutoCompleteController : nsISupports
{
/*
@ -152,4 +153,10 @@ interface nsIAutoCompleteController : nsISupports
* Set the current search string, but don't start searching
*/
void setSearchString(in AString aSearchString);
/*
* Attach or Detach roolup-listener
*/
void attachRollupListener();
void detachRollupListener();
};

Просмотреть файл

@ -57,6 +57,11 @@ REQUIRES = xpcom \
layout \
unicharutil \
toolkitcomps \
widget \
content \
view \
gfx \
locale \
$(NULL)
CPPSRCS = nsAutoCompleteController.cpp \

Просмотреть файл

@ -47,7 +47,14 @@
#include "nsToolkitCompsCID.h"
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIView.h"
#include "nsIPresShell.h"
#include "nsIAtomService.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
@ -58,7 +65,11 @@ static const char *kAutoCompleteSearchCID = "@mozilla.org/autocomplete/search;1?
// static const char *kCompleteConcatSeparator = " >> ";
NS_IMPL_ISUPPORTS4(nsAutoCompleteController, nsIAutoCompleteController, nsIAutoCompleteObserver, nsITimerCallback, nsITreeView)
NS_IMPL_ISUPPORTS5(nsAutoCompleteController, nsIAutoCompleteController,
nsIAutoCompleteObserver,
nsIRollupListener,
nsITimerCallback,
nsITreeView)
nsAutoCompleteController::nsAutoCompleteController() :
mEnterAfterSearch(PR_FALSE),
@ -578,6 +589,24 @@ nsAutoCompleteController::SetSearchString(const nsAString &aSearchString)
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteController::AttachRollupListener()
{
nsIWidget* widget = GetPopupWidget();
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
return widget->CaptureRollupEvents((nsIRollupListener*)this,
PR_TRUE, PR_FALSE);
}
NS_IMETHODIMP
nsAutoCompleteController::DetachRollupListener()
{
nsIWidget* widget = GetPopupWidget();
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
return widget->CaptureRollupEvents((nsIRollupListener*)this,
PR_FALSE, PR_FALSE);
}
////////////////////////////////////////////////////////////////////////
//// nsIAutoCompleteObserver
@ -598,6 +627,32 @@ nsAutoCompleteController::OnSearchResult(nsIAutoCompleteSearch *aSearch, nsIAuto
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//// nsIRollupListener
NS_IMETHODIMP
nsAutoCompleteController::Rollup()
{
ClearSearchTimer();
ClearResults();
ClosePopup();
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteController::ShouldRollupOnMouseWheelEvent(PRBool *aShouldRollup)
{
*aShouldRollup = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteController::ShouldRollupOnMouseActivate(PRBool *aShouldRollup)
{
*aShouldRollup = PR_FALSE;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//// nsITimerCallback
@ -1275,6 +1330,37 @@ nsAutoCompleteController::RowIndexToSearch(PRInt32 aRowIndex, PRInt32 *aSearchIn
return NS_OK;
}
nsIWidget*
nsAutoCompleteController::GetPopupWidget()
{
NS_ENSURE_TRUE(mInput, nsnull);
nsCOMPtr<nsIAutoCompletePopup> autoCompletePopup;
mInput->GetPopup(getter_AddRefs(autoCompletePopup));
NS_ENSURE_TRUE(autoCompletePopup, nsnull);
nsCOMPtr<nsIDOMNode> popup = do_QueryInterface(autoCompletePopup);
NS_ENSURE_TRUE(popup, nsnull);
nsCOMPtr<nsIDOMDocument> domDoc;
popup->GetOwnerDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsIPresShell* presShell = doc->GetShellAt(0);
nsCOMPtr<nsIContent> content = do_QueryInterface(popup);
nsIFrame* frame = presShell->GetPrimaryFrameFor(content);
while (frame) {
nsIView* view = frame->GetViewExternal();
if (view && view->HasWidget())
return view->GetWidget();
frame = frame->GetParent();
}
NS_ERROR("widget wasn't found!");
return nsnull;
}
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteController)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteSimpleResult)
#ifdef MOZ_MORK

Просмотреть файл

@ -20,6 +20,7 @@
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (Original Author)
* Masayuki Nakano <masayuki@d-toybox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -49,9 +50,12 @@
#include "nsITreeSelection.h"
#include "nsISupportsArray.h"
#include "nsITimer.h"
#include "nsIRollupListener.h"
#include "nsIWidget.h"
class nsAutoCompleteController : public nsIAutoCompleteController,
public nsIAutoCompleteObserver,
public nsIRollupListener,
public nsITimerCallback,
public nsITreeView
{
@ -59,6 +63,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIAUTOCOMPLETECONTROLLER
NS_DECL_NSIAUTOCOMPLETEOBSERVER
NS_DECL_NSIROLLUPLISTENER
NS_DECL_NSITREEVIEW
NS_DECL_NSITIMERCALLBACK
@ -89,6 +94,8 @@ protected:
nsresult RowIndexToSearch(PRInt32 aRowIndex, PRInt32 *aSearchIndex, PRInt32 *aItemIndex);
nsIWidget* GetPopupWidget();
// members //////////////////////////////////////////
nsCOMPtr<nsIAutoCompleteInput> mInput;

Просмотреть файл

@ -24,6 +24,7 @@
# Contributor(s):
# Pierre Chanial (p_ch@verizon.net)
# Dean Tessman (dean_tessman@hotmail.com)
# Masayuki Nakano (masayuki@d-toybox.com)
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -574,6 +575,8 @@
else {
this.showPopup(document.documentElement, aX, aY, "popup", null, null);
}
this.enableRollup(false);
this.mInput.controller.attachRollupListener();
}
]]></body>
</method>
@ -585,6 +588,7 @@
document.popupNode = null;
this.setAttribute("hidden", "true");
this.mInput.controller.detachRollupListener();
}
]]></body>
</method>