зеркало из 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) {
|
if (aEvent->message == NS_KEY_PRESS) {
|
||||||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||||
nsInputEvent *inputEvent = (nsInputEvent*)aEvent;
|
nsInputEvent *inputEvent = (nsInputEvent*)aEvent;
|
||||||
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta) {
|
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta &&
|
||||||
if (keyEvent->keyCode == NS_VK_F4 && !inputEvent->isAlt)
|
!mDroppedDown && keyEvent->keyCode == NS_VK_RETURN) {
|
||||||
ToggleList(aPresContext);
|
CheckFireOnChange();
|
||||||
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 we have style that affects how we are selected, feed event down to
|
// If we have style that affects how we are selected, feed event down to
|
||||||
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
||||||
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
||||||
|
|
|
@ -3243,6 +3243,17 @@ nsListControlFrame::GetIncrementalString()
|
||||||
return incrementalString;
|
return incrementalString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent)
|
||||||
|
{
|
||||||
|
if (IsInDropDownMode()) {
|
||||||
|
PRBool isDroppedDown;
|
||||||
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||||
|
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||||
|
aKeyEvent->PreventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
{
|
{
|
||||||
|
@ -3269,23 +3280,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
|
|
||||||
keyEvent->GetAltKey(&isAlt);
|
keyEvent->GetAltKey(&isAlt);
|
||||||
if (isAlt) {
|
if (isAlt) {
|
||||||
#ifdef FIX_FOR_BUG_62425
|
if (keycode == nsIDOMKeyEvent::DOM_VK_UP || keycode == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||||
if (code == nsIDOMKeyEvent::DOM_VK_UP || code == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
DropDownToggleKey(aKeyEvent);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3388,19 +3385,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
|
|
||||||
#if defined(XP_WIN) || defined(XP_OS2)
|
#if defined(XP_WIN) || defined(XP_OS2)
|
||||||
case nsIDOMKeyEvent::DOM_VK_F4: {
|
case nsIDOMKeyEvent::DOM_VK_F4: {
|
||||||
if (IsInDropDownMode() == PR_TRUE) {
|
DropDownToggleKey(aKeyEvent);
|
||||||
PRBool isDroppedDown;
|
return NS_OK;
|
||||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
} break;
|
||||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
|
||||||
|
|
||||||
if (nsevent) {
|
|
||||||
nsevent->PreventCapture();
|
|
||||||
nsevent->PreventBubble();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case nsIDOMKeyEvent::DOM_VK_TAB: {
|
case nsIDOMKeyEvent::DOM_VK_TAB: {
|
||||||
|
|
|
@ -336,6 +336,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void DropDownToggleKey(nsIDOMEvent* aKeyEvent);
|
||||||
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||||
nsresult ScrollToFrame(nsIContent * aOptElement);
|
nsresult ScrollToFrame(nsIContent * aOptElement);
|
||||||
nsresult ScrollToIndex(PRInt32 anIndex);
|
nsresult ScrollToIndex(PRInt32 anIndex);
|
||||||
|
|
|
@ -1996,18 +1996,12 @@ nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||||
if (aEvent->message == NS_KEY_PRESS) {
|
if (aEvent->message == NS_KEY_PRESS) {
|
||||||
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent;
|
||||||
nsInputEvent *inputEvent = (nsInputEvent*)aEvent;
|
nsInputEvent *inputEvent = (nsInputEvent*)aEvent;
|
||||||
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta) {
|
if (!inputEvent->isShift && !inputEvent->isControl && !inputEvent->isMeta &&
|
||||||
if (keyEvent->keyCode == NS_VK_F4 && !inputEvent->isAlt)
|
!mDroppedDown && keyEvent->keyCode == NS_VK_RETURN) {
|
||||||
ToggleList(aPresContext);
|
CheckFireOnChange();
|
||||||
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 we have style that affects how we are selected, feed event down to
|
// If we have style that affects how we are selected, feed event down to
|
||||||
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
// nsFrame::HandleEvent so that selection takes place when appropriate.
|
||||||
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
||||||
|
|
|
@ -3243,6 +3243,17 @@ nsListControlFrame::GetIncrementalString()
|
||||||
return incrementalString;
|
return incrementalString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent)
|
||||||
|
{
|
||||||
|
if (IsInDropDownMode()) {
|
||||||
|
PRBool isDroppedDown;
|
||||||
|
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
||||||
|
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
||||||
|
aKeyEvent->PreventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
{
|
{
|
||||||
|
@ -3269,23 +3280,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
|
|
||||||
keyEvent->GetAltKey(&isAlt);
|
keyEvent->GetAltKey(&isAlt);
|
||||||
if (isAlt) {
|
if (isAlt) {
|
||||||
#ifdef FIX_FOR_BUG_62425
|
if (keycode == nsIDOMKeyEvent::DOM_VK_UP || keycode == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||||
if (code == nsIDOMKeyEvent::DOM_VK_UP || code == nsIDOMKeyEvent::DOM_VK_DOWN) {
|
DropDownToggleKey(aKeyEvent);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3388,19 +3385,9 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
|
|
||||||
#if defined(XP_WIN) || defined(XP_OS2)
|
#if defined(XP_WIN) || defined(XP_OS2)
|
||||||
case nsIDOMKeyEvent::DOM_VK_F4: {
|
case nsIDOMKeyEvent::DOM_VK_F4: {
|
||||||
if (IsInDropDownMode() == PR_TRUE) {
|
DropDownToggleKey(aKeyEvent);
|
||||||
PRBool isDroppedDown;
|
return NS_OK;
|
||||||
mComboboxFrame->IsDroppedDown(&isDroppedDown);
|
} break;
|
||||||
mComboboxFrame->ShowDropDown(!isDroppedDown);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNSEvent> nsevent(do_QueryInterface(aKeyEvent));
|
|
||||||
|
|
||||||
if (nsevent) {
|
|
||||||
nsevent->PreventCapture();
|
|
||||||
nsevent->PreventBubble();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case nsIDOMKeyEvent::DOM_VK_TAB: {
|
case nsIDOMKeyEvent::DOM_VK_TAB: {
|
||||||
|
|
|
@ -336,6 +336,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
void DropDownToggleKey(nsIDOMEvent* aKeyEvent);
|
||||||
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||||
nsresult ScrollToFrame(nsIContent * aOptElement);
|
nsresult ScrollToFrame(nsIContent * aOptElement);
|
||||||
nsresult ScrollToIndex(PRInt32 anIndex);
|
nsresult ScrollToIndex(PRInt32 anIndex);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче