зеркало из https://github.com/mozilla/gecko-dev.git
Bug 211846. alt+down not working consistently for dropdowns. Also fixes bug 110801 and bug 205942, dropdown from alt+down not showing in the right place. r=jkieser, sr=bz
This commit is contained in:
Родитель
7aaa87d0a9
Коммит
5c5a6660ec
|
@ -1996,18 +1996,12 @@ nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (aEvent->message == NS_KEY_PRESS) {
|
||||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||
nsInputEvent *inputEvent = (nsInputEvent*)aEvent;
|
||||
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta) {
|
||||
if (keyEvent->keyCode == NS_VK_F4 && !inputEvent->isAlt)
|
||||
ToggleList(aPresContext);
|
||||
else if (inputEvent->isAlt && (keyEvent->keyCode == NS_VK_DOWN || (mDroppedDown && keyEvent->keyCode == NS_VK_UP)))
|
||||
ToggleList(aPresContext);
|
||||
else if (!mDroppedDown && keyEvent->keyCode == NS_VK_RETURN)
|
||||
CheckFireOnChange();
|
||||
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta &&
|
||||
!mDroppedDown && keyEvent->keyCode == NS_VK_RETURN) {
|
||||
CheckFireOnChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If we have style that affects how we are selected, feed event down to
|
||||
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
||||
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
||||
|
|
|
@ -3243,6 +3243,17 @@ nsListControlFrame::GetIncrementalString()
|
|||
return incrementalString;
|
||||
}
|
||||
|
||||
void
|
||||
nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
if (IsInDropDownMode()) {
|
||||
PRBool isDroppedDown;
|
||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
|
@ -3269,23 +3280,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
|
||||
keyEvent->GetAltKey(&isAlt);
|
||||
if (isAlt) {
|
||||
#ifdef FIX_FOR_BUG_62425
|
||||
if (code == nsIDOMKeyEvent::DOM_VK_UP || code == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||
if (IsInDropDownMode() == PR_TRUE) {
|
||||
PRBool isDroppedDown;
|
||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||
aKeyEvent->PreventDefault();
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
||||
|
||||
if (nsevent) {
|
||||
nsevent->PreventCapture();
|
||||
nsevent->PreventBubble();
|
||||
}
|
||||
}
|
||||
if (keycode == nsIDOMKeyEvent::DOM_VK_UP || keycode == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||
DropDownToggleKey(aKeyEvent);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3388,19 +3385,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
case nsIDOMKeyEvent::DOM_VK_F4: {
|
||||
if (IsInDropDownMode() == PR_TRUE) {
|
||||
PRBool isDroppedDown;
|
||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
||||
|
||||
if (nsevent) {
|
||||
nsevent->PreventCapture();
|
||||
nsevent->PreventBubble();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
DropDownToggleKey(aKeyEvent);
|
||||
return NS_OK;
|
||||
} break;
|
||||
#endif
|
||||
|
||||
case nsIDOMKeyEvent::DOM_VK_TAB: {
|
||||
|
|
|
@ -336,6 +336,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
void DropDownToggleKey(nsIDOMEvent* aKeyEvent);
|
||||
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||
nsresult ScrollToFrame(nsIContent * aOptElement);
|
||||
nsresult ScrollToIndex(PRInt32 anIndex);
|
||||
|
|
|
@ -1996,18 +1996,12 @@ nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (aEvent->message == NS_KEY_PRESS) {
|
||||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||
nsInputEvent *inputEvent = (nsInputEvent*)aEvent;
|
||||
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta) {
|
||||
if (keyEvent->keyCode == NS_VK_F4 && !inputEvent->isAlt)
|
||||
ToggleList(aPresContext);
|
||||
else if (inputEvent->isAlt && (keyEvent->keyCode == NS_VK_DOWN || (mDroppedDown && keyEvent->keyCode == NS_VK_UP)))
|
||||
ToggleList(aPresContext);
|
||||
else if (!mDroppedDown && keyEvent->keyCode == NS_VK_RETURN)
|
||||
CheckFireOnChange();
|
||||
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta &&
|
||||
!mDroppedDown && keyEvent->keyCode == NS_VK_RETURN) {
|
||||
CheckFireOnChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If we have style that affects how we are selected, feed event down to
|
||||
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
||||
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
||||
|
|
|
@ -3243,6 +3243,17 @@ nsListControlFrame::GetIncrementalString()
|
|||
return incrementalString;
|
||||
}
|
||||
|
||||
void
|
||||
nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
if (IsInDropDownMode()) {
|
||||
PRBool isDroppedDown;
|
||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
|
@ -3269,23 +3280,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
|
||||
keyEvent->GetAltKey(&isAlt);
|
||||
if (isAlt) {
|
||||
#ifdef FIX_FOR_BUG_62425
|
||||
if (code == nsIDOMKeyEvent::DOM_VK_UP || code == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||
if (IsInDropDownMode() == PR_TRUE) {
|
||||
PRBool isDroppedDown;
|
||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||
aKeyEvent->PreventDefault();
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
||||
|
||||
if (nsevent) {
|
||||
nsevent->PreventCapture();
|
||||
nsevent->PreventBubble();
|
||||
}
|
||||
}
|
||||
if (keycode == nsIDOMKeyEvent::DOM_VK_UP || keycode == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||
DropDownToggleKey(aKeyEvent);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3388,19 +3385,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
case nsIDOMKeyEvent::DOM_VK_F4: {
|
||||
if (IsInDropDownMode() == PR_TRUE) {
|
||||
PRBool isDroppedDown;
|
||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||
|
||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
||||
|
||||
if (nsevent) {
|
||||
nsevent->PreventCapture();
|
||||
nsevent->PreventBubble();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
DropDownToggleKey(aKeyEvent);
|
||||
return NS_OK;
|
||||
} break;
|
||||
#endif
|
||||
|
||||
case nsIDOMKeyEvent::DOM_VK_TAB: {
|
||||
|
|
|
@ -336,6 +336,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
void DropDownToggleKey(nsIDOMEvent* aKeyEvent);
|
||||
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||
nsresult ScrollToFrame(nsIContent * aOptElement);
|
||||
nsresult ScrollToIndex(PRInt32 anIndex);
|
||||
|
|
Загрузка…
Ссылка в новой задаче