зеркало из https://github.com/mozilla/pjs.git
Bug 187772 mouse wheel scrolling does not dismiss form auto complete history, results in floating autocomplete dropdown r=mconnor
This commit is contained in:
Родитель
1d2adbe0ad
Коммит
79d8af6102
|
@ -21,6 +21,7 @@
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Joe Hewitt <hewitt@netscape.com> (Original Author)
|
* Joe Hewitt <hewitt@netscape.com> (Original Author)
|
||||||
* Dean Tessman <dean_tessman@hotmail.com>
|
* 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
|
* 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
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
|
|
||||||
interface nsIAutoCompleteInput;
|
interface nsIAutoCompleteInput;
|
||||||
|
|
||||||
[scriptable, uuid(CF2ACA0C-4FB1-42e4-8A54-23E832CB2A98)]
|
[scriptable, uuid(8E62F092-DD82-4748-BAB3-8898C7C881A1)]
|
||||||
interface nsIAutoCompleteController : nsISupports
|
interface nsIAutoCompleteController : nsISupports
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -152,4 +153,10 @@ interface nsIAutoCompleteController : nsISupports
|
||||||
* Set the current search string, but don't start searching
|
* Set the current search string, but don't start searching
|
||||||
*/
|
*/
|
||||||
void setSearchString(in AString aSearchString);
|
void setSearchString(in AString aSearchString);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attach or Detach roolup-listener
|
||||||
|
*/
|
||||||
|
void attachRollupListener();
|
||||||
|
void detachRollupListener();
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,11 @@ REQUIRES = xpcom \
|
||||||
layout \
|
layout \
|
||||||
unicharutil \
|
unicharutil \
|
||||||
toolkitcomps \
|
toolkitcomps \
|
||||||
|
widget \
|
||||||
|
content \
|
||||||
|
view \
|
||||||
|
gfx \
|
||||||
|
locale \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CPPSRCS = nsAutoCompleteController.cpp \
|
CPPSRCS = nsAutoCompleteController.cpp \
|
||||||
|
|
|
@ -47,7 +47,14 @@
|
||||||
|
|
||||||
#include "nsToolkitCompsCID.h"
|
#include "nsToolkitCompsCID.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
|
#include "nsIDOMNode.h"
|
||||||
#include "nsIDOMElement.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 "nsIAtomService.h"
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
|
@ -58,7 +65,11 @@ static const char *kAutoCompleteSearchCID = "@mozilla.org/autocomplete/search;1?
|
||||||
|
|
||||||
// static const char *kCompleteConcatSeparator = " >> ";
|
// static const char *kCompleteConcatSeparator = " >> ";
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS4(nsAutoCompleteController, nsIAutoCompleteController, nsIAutoCompleteObserver, nsITimerCallback, nsITreeView)
|
NS_IMPL_ISUPPORTS5(nsAutoCompleteController, nsIAutoCompleteController,
|
||||||
|
nsIAutoCompleteObserver,
|
||||||
|
nsIRollupListener,
|
||||||
|
nsITimerCallback,
|
||||||
|
nsITreeView)
|
||||||
|
|
||||||
nsAutoCompleteController::nsAutoCompleteController() :
|
nsAutoCompleteController::nsAutoCompleteController() :
|
||||||
mEnterAfterSearch(PR_FALSE),
|
mEnterAfterSearch(PR_FALSE),
|
||||||
|
@ -578,6 +589,24 @@ nsAutoCompleteController::SetSearchString(const nsAString &aSearchString)
|
||||||
return NS_OK;
|
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
|
//// nsIAutoCompleteObserver
|
||||||
|
|
||||||
|
@ -598,6 +627,32 @@ nsAutoCompleteController::OnSearchResult(nsIAutoCompleteSearch *aSearch, nsIAuto
|
||||||
return NS_OK;
|
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
|
//// nsITimerCallback
|
||||||
|
|
||||||
|
@ -1275,6 +1330,37 @@ nsAutoCompleteController::RowIndexToSearch(PRInt32 aRowIndex, PRInt32 *aSearchIn
|
||||||
return NS_OK;
|
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(nsAutoCompleteController)
|
||||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteSimpleResult)
|
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAutoCompleteSimpleResult)
|
||||||
#ifdef MOZ_MORK
|
#ifdef MOZ_MORK
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Joe Hewitt <hewitt@netscape.com> (Original Author)
|
* 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
|
* 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
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
@ -49,9 +50,12 @@
|
||||||
#include "nsITreeSelection.h"
|
#include "nsITreeSelection.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
|
#include "nsIRollupListener.h"
|
||||||
|
#include "nsIWidget.h"
|
||||||
|
|
||||||
class nsAutoCompleteController : public nsIAutoCompleteController,
|
class nsAutoCompleteController : public nsIAutoCompleteController,
|
||||||
public nsIAutoCompleteObserver,
|
public nsIAutoCompleteObserver,
|
||||||
|
public nsIRollupListener,
|
||||||
public nsITimerCallback,
|
public nsITimerCallback,
|
||||||
public nsITreeView
|
public nsITreeView
|
||||||
{
|
{
|
||||||
|
@ -59,6 +63,7 @@ public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIAUTOCOMPLETECONTROLLER
|
NS_DECL_NSIAUTOCOMPLETECONTROLLER
|
||||||
NS_DECL_NSIAUTOCOMPLETEOBSERVER
|
NS_DECL_NSIAUTOCOMPLETEOBSERVER
|
||||||
|
NS_DECL_NSIROLLUPLISTENER
|
||||||
NS_DECL_NSITREEVIEW
|
NS_DECL_NSITREEVIEW
|
||||||
NS_DECL_NSITIMERCALLBACK
|
NS_DECL_NSITIMERCALLBACK
|
||||||
|
|
||||||
|
@ -89,6 +94,8 @@ protected:
|
||||||
|
|
||||||
nsresult RowIndexToSearch(PRInt32 aRowIndex, PRInt32 *aSearchIndex, PRInt32 *aItemIndex);
|
nsresult RowIndexToSearch(PRInt32 aRowIndex, PRInt32 *aSearchIndex, PRInt32 *aItemIndex);
|
||||||
|
|
||||||
|
nsIWidget* GetPopupWidget();
|
||||||
|
|
||||||
// members //////////////////////////////////////////
|
// members //////////////////////////////////////////
|
||||||
|
|
||||||
nsCOMPtr<nsIAutoCompleteInput> mInput;
|
nsCOMPtr<nsIAutoCompleteInput> mInput;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
# Contributor(s):
|
# Contributor(s):
|
||||||
# Pierre Chanial (p_ch@verizon.net)
|
# Pierre Chanial (p_ch@verizon.net)
|
||||||
# Dean Tessman (dean_tessman@hotmail.com)
|
# 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
|
# 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
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
@ -574,6 +575,8 @@
|
||||||
else {
|
else {
|
||||||
this.showPopup(document.documentElement, aX, aY, "popup", null, null);
|
this.showPopup(document.documentElement, aX, aY, "popup", null, null);
|
||||||
}
|
}
|
||||||
|
this.enableRollup(false);
|
||||||
|
this.mInput.controller.attachRollupListener();
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
@ -585,6 +588,7 @@
|
||||||
document.popupNode = null;
|
document.popupNode = null;
|
||||||
|
|
||||||
this.setAttribute("hidden", "true");
|
this.setAttribute("hidden", "true");
|
||||||
|
this.mInput.controller.detachRollupListener();
|
||||||
}
|
}
|
||||||
]]></body>
|
]]></body>
|
||||||
</method>
|
</method>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче