Bug 1436508 part 6. Switch layout/xul from nsIDOMKeyEvent to KeyboardEvent. r=masayuki

MozReview-Commit-ID: Cp4krHgxXzQ
This commit is contained in:
Boris Zbarsky 2018-02-09 11:17:09 -05:00
parent 696520edca
commit 7e7ef3c600
10 changed files with 109 additions and 106 deletions

View File

@ -9,7 +9,6 @@
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/Element.h"
#include "nsIDOMKeyEvent.h"
#include "nsIFrame.h"
#include "nsMenuBarFrame.h"
#include "nsMenuBarListener.h"

View File

@ -28,8 +28,10 @@
#include "nsUTF8Utils.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/KeyboardEvent.h"
using namespace mozilla;
using mozilla::dom::KeyboardEvent;
//
// NS_NewMenuBarFrame
@ -144,14 +146,13 @@ nsMenuBarFrame::ToggleMenuActiveState()
}
nsMenuFrame*
nsMenuBarFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, bool aPeek)
nsMenuBarFrame::FindMenuWithShortcut(KeyboardEvent* aKeyEvent, bool aPeek)
{
uint32_t charCode;
aKeyEvent->GetCharCode(&charCode);
uint32_t charCode = aKeyEvent->CharCode();
AutoTArray<uint32_t, 10> accessKeys;
WidgetKeyboardEvent* nativeKeyEvent =
aKeyEvent->AsEvent()->WidgetEventPtr()->AsKeyboardEvent();
aKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
if (nativeKeyEvent) {
nativeKeyEvent->GetAccessKeyCandidates(accessKeys);
}

View File

@ -21,6 +21,12 @@
class nsIContent;
namespace mozilla {
namespace dom {
class KeyboardEvent;
} // namespace dom
} // namespace mozilla
nsIFrame* NS_NewMenuBarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
class nsMenuBarFrame final : public nsBoxFrame, public nsMenuParent
@ -85,7 +91,8 @@ public:
nsMenuFrame* Enter(mozilla::WidgetGUIEvent* aEvent);
// Used to handle ALT+key combos
nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, bool aPeek);
nsMenuFrame* FindMenuWithShortcut(mozilla::dom::KeyboardEvent* aKeyEvent,
bool aPeek);
virtual bool IsFrameOfType(uint32_t aFlags) const override
{

View File

@ -14,7 +14,6 @@
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsCOMPtr.h"
#include "nsIDOMKeyEvent.h"
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
@ -23,8 +22,10 @@
#include "mozilla/BasicEvents.h"
#include "mozilla/Preferences.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/KeyboardEvent.h"
using namespace mozilla;
using mozilla::dom::KeyboardEvent;
/*
* nsMenuBarListener implementation
@ -181,7 +182,8 @@ nsMenuBarListener::ToggleMenuActiveState()
nsresult
nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
{
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
RefPtr<KeyboardEvent> keyEvent =
aKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
if (!keyEvent) {
return NS_OK;
}
@ -189,23 +191,18 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
InitAccessKey();
//handlers shouldn't be triggered by non-trusted events.
bool trustedEvent = false;
aKeyEvent->GetIsTrusted(&trustedEvent);
if (!trustedEvent) {
if (!keyEvent->IsTrusted()) {
return NS_OK;
}
if (mAccessKey && mAccessKeyFocuses)
{
bool defaultPrevented = false;
aKeyEvent->GetDefaultPrevented(&defaultPrevented);
bool defaultPrevented = keyEvent->DefaultPrevented();
// On a press of the ALT key by itself, we toggle the menu's
// active/inactive state.
// Get the ascii key code.
uint32_t theChar;
keyEvent->GetKeyCode(&theChar);
uint32_t theChar = keyEvent->KeyCode();
if (!defaultPrevented && mAccessKeyDown && !mAccessKeyDownCanceled &&
(int32_t)theChar == mAccessKey)
@ -237,8 +234,8 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
bool active = !Destroyed() && mMenuBarFrame->IsActive();
if (active) {
aKeyEvent->StopPropagation();
aKeyEvent->PreventDefault();
keyEvent->StopPropagation();
keyEvent->PreventDefault();
return NS_OK; // I am consuming event
}
}
@ -281,9 +278,9 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
uint32_t keyCode;
keyEvent->GetKeyCode(&keyCode);
RefPtr<KeyboardEvent> keyEvent =
aKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
uint32_t keyCode = keyEvent->KeyCode();
// Cancel the access key flag unless we are pressing the access key.
if (keyCode != (uint32_t)mAccessKey) {
@ -357,7 +354,7 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
}
bool
nsMenuBarListener::IsAccessKeyPressed(nsIDOMKeyEvent* aKeyEvent)
nsMenuBarListener::IsAccessKeyPressed(KeyboardEvent* aKeyEvent)
{
InitAccessKey();
// No other modifiers are allowed to be down except for Shift.
@ -369,10 +366,10 @@ nsMenuBarListener::IsAccessKeyPressed(nsIDOMKeyEvent* aKeyEvent)
}
Modifiers
nsMenuBarListener::GetModifiersForAccessKey(nsIDOMKeyEvent* aKeyEvent)
nsMenuBarListener::GetModifiersForAccessKey(KeyboardEvent* aKeyEvent)
{
WidgetInputEvent* inputEvent =
aKeyEvent->AsEvent()->WidgetEventPtr()->AsInputEvent();
aKeyEvent->WidgetEventPtr()->AsInputEvent();
MOZ_ASSERT(inputEvent);
static const Modifiers kPossibleModifiersForAccessKey =
@ -382,18 +379,17 @@ nsMenuBarListener::GetModifiersForAccessKey(nsIDOMKeyEvent* aKeyEvent)
}
nsMenuFrame*
nsMenuBarListener::GetMenuForKeyEvent(nsIDOMKeyEvent* aKeyEvent, bool aPeek)
nsMenuBarListener::GetMenuForKeyEvent(KeyboardEvent* aKeyEvent, bool aPeek)
{
if (!IsAccessKeyPressed(aKeyEvent)) {
return nullptr;
}
uint32_t charCode;
aKeyEvent->GetCharCode(&charCode);
uint32_t charCode = aKeyEvent->CharCode();
bool hasAccessKeyCandidates = charCode != 0;
if (!hasAccessKeyCandidates) {
WidgetKeyboardEvent* nativeKeyEvent =
aKeyEvent->AsEvent()->WidgetEventPtr()->AsKeyboardEvent();
aKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
AutoTArray<uint32_t, 10> keys;
nativeKeyEvent->GetAccessKeyCandidates(keys);
@ -436,16 +432,15 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
RefPtr<KeyboardEvent> keyEvent =
aKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
if (!keyEvent) {
return NS_OK;
}
uint32_t theChar;
keyEvent->GetKeyCode(&theChar);
uint32_t theChar = keyEvent->KeyCode();
uint16_t eventPhase;
aKeyEvent->GetEventPhase(&eventPhase);
uint16_t eventPhase = keyEvent->EventPhase();
bool capturing = (eventPhase == nsIDOMEvent::CAPTURING_PHASE);
#ifndef XP_MACOSX

View File

@ -17,11 +17,11 @@
class nsMenuFrame;
class nsMenuBarFrame;
class nsIDOMKeyEvent;
namespace mozilla {
namespace dom {
class EventTarget;
class KeyboardEvent;
} // namespace dom
} // namespace mozilla
@ -58,7 +58,7 @@ public:
* IsAccessKeyPressed() returns true if the modifier state of aEvent matches
* the modifier state of access key.
*/
static bool IsAccessKeyPressed(nsIDOMKeyEvent* aEvent);
static bool IsAccessKeyPressed(mozilla::dom::KeyboardEvent* aEvent);
protected:
virtual ~nsMenuBarListener();
@ -73,14 +73,15 @@ protected:
static void InitAccessKey();
static mozilla::Modifiers GetModifiersForAccessKey(nsIDOMKeyEvent* event);
static mozilla::Modifiers
GetModifiersForAccessKey(mozilla::dom::KeyboardEvent* event);
/**
* Given a key event for an Alt+shortcut combination,
* return the menu, if any, that would be opened. If aPeek
* is false, then play a beep and deactivate the menubar on Windows.
*/
nsMenuFrame* GetMenuForKeyEvent(nsIDOMKeyEvent* aKeyEvent, bool aPeek);
nsMenuFrame* GetMenuForKeyEvent(mozilla::dom::KeyboardEvent* aKeyEvent, bool aPeek);
/**
* Call MarkAsReservedByChrome if the user's preferences indicate that

View File

@ -25,7 +25,6 @@
#include "nsBindingManager.h"
#include "nsIServiceManager.h"
#include "nsCSSFrameConstructor.h"
#include "nsIDOMKeyEvent.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"

View File

@ -19,7 +19,6 @@
#include "nsPopupSetFrame.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMEvent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMScreen.h"
#include "nsIDOMXULMenuListElement.h"
#include "nsIPresShell.h"
@ -56,11 +55,13 @@
#include "mozilla/MouseEvents.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/PopupBoxObject.h"
#include <algorithm>
using namespace mozilla;
using mozilla::dom::PopupBoxObject;
using mozilla::dom::KeyboardEvent;
int8_t nsMenuPopupFrame::sDefaultLevelIsTop = -1;
@ -2081,11 +2082,10 @@ nsMenuPopupFrame::Enter(WidgetGUIEvent* aEvent)
}
nsMenuFrame*
nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, bool& doAction)
nsMenuPopupFrame::FindMenuWithShortcut(KeyboardEvent* aKeyEvent, bool& doAction)
{
uint32_t charCode, keyCode;
aKeyEvent->GetCharCode(&charCode);
aKeyEvent->GetKeyCode(&keyCode);
uint32_t charCode = aKeyEvent->CharCode();
uint32_t keyCode = aKeyEvent->KeyCode();
doAction = false;
@ -2103,8 +2103,7 @@ nsMenuPopupFrame::FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, bool& doAction
bool isMenu = parentContent &&
!parentContent->NodeInfo()->Equals(nsGkAtoms::menulist, kNameSpaceID_XUL);
DOMTimeStamp keyTime;
aKeyEvent->AsEvent()->GetTimeStamp(&keyTime);
DOMTimeStamp keyTime = aKeyEvent->TimeStamp();
if (charCode == 0) {
if (keyCode == nsIDOMKeyEvent::DOM_VK_BACK_SPACE) {

View File

@ -27,6 +27,12 @@
class nsIWidget;
namespace mozilla {
namespace dom {
class KeyboardEvent;
} // namespace dom
} // namespace mozilla
// XUL popups can be in several different states. When opening a popup, the
// state changes as follows:
// ePopupClosed - initial state
@ -339,7 +345,8 @@ public:
// the Enter key. If doAction is false, the menu should just be highlighted.
// This method also handles incremental searching in menus so the user can
// type the first few letters of an item/s name to select it.
nsMenuFrame* FindMenuWithShortcut(nsIDOMKeyEvent* aKeyEvent, bool& doAction);
nsMenuFrame* FindMenuWithShortcut(mozilla::dom::KeyboardEvent* aKeyEvent,
bool& doAction);
void ClearIncrementalString() { mIncrementalString.Truncate(); }
static bool IsWithinIncrementalTime(DOMTimeStamp time) {

View File

@ -27,7 +27,6 @@
#include "nsPIDOMWindow.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIBaseWindow.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsCaret.h"
#include "nsIDocument.h"
@ -37,6 +36,7 @@
#include "XULDocument.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
#include "mozilla/dom/KeyboardEvent.h"
#include "mozilla/dom/UIEvent.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStateManager.h"
@ -2103,12 +2103,12 @@ nsXULPopupManager::CancelMenuTimer(nsMenuParent* aMenuParent)
}
bool
nsXULPopupManager::HandleShortcutNavigation(nsIDOMKeyEvent* aKeyEvent,
nsXULPopupManager::HandleShortcutNavigation(KeyboardEvent* aKeyEvent,
nsMenuPopupFrame* aFrame)
{
// On Windows, don't check shortcuts when the accelerator key is down.
#ifdef XP_WIN
WidgetInputEvent* evt = aKeyEvent->AsEvent()->WidgetEventPtr()->AsInputEvent();
WidgetInputEvent* evt = aKeyEvent->WidgetEventPtr()->AsInputEvent();
if (evt && evt->IsAccel()) {
return false;
}
@ -2124,7 +2124,7 @@ nsXULPopupManager::HandleShortcutNavigation(nsIDOMKeyEvent* aKeyEvent,
if (result) {
aFrame->ChangeMenuItem(result, false, true);
if (action) {
WidgetGUIEvent* evt = aKeyEvent->AsEvent()->WidgetEventPtr()->AsGUIEvent();
WidgetGUIEvent* evt = aKeyEvent->WidgetEventPtr()->AsGUIEvent();
nsMenuFrame* menuToOpen = result->Enter(evt);
if (menuToOpen) {
nsCOMPtr<nsIContent> content = menuToOpen->GetContent();
@ -2329,20 +2329,19 @@ nsXULPopupManager::HandleKeyboardNavigationInPopup(nsMenuChainItem* item,
bool
nsXULPopupManager::HandleKeyboardEventWithKeyCode(
nsIDOMKeyEvent* aKeyEvent,
KeyboardEvent* aKeyEvent,
nsMenuChainItem* aTopVisibleMenuItem)
{
uint32_t keyCode;
aKeyEvent->GetKeyCode(&keyCode);
uint32_t keyCode = aKeyEvent->KeyCode();
// Escape should close panels, but the other keys should have no effect.
if (aTopVisibleMenuItem &&
aTopVisibleMenuItem->PopupType() != ePopupTypeMenu) {
if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) {
HidePopup(aTopVisibleMenuItem->Content(), false, false, false, true);
aKeyEvent->AsEvent()->StopPropagation();
aKeyEvent->AsEvent()->StopCrossProcessForwarding();
aKeyEvent->AsEvent()->PreventDefault();
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
}
return true;
}
@ -2353,9 +2352,9 @@ nsXULPopupManager::HandleKeyboardEventWithKeyCode(
case nsIDOMKeyEvent::DOM_VK_DOWN:
#ifndef XP_MACOSX
// roll up the popup when alt+up/down are pressed within a menulist.
bool alt;
aKeyEvent->GetAltKey(&alt);
if (alt && aTopVisibleMenuItem && aTopVisibleMenuItem->Frame()->IsMenuList()) {
if (aKeyEvent->AltKey() &&
aTopVisibleMenuItem &&
aTopVisibleMenuItem->Frame()->IsMenuList()) {
Rollup(0, false, nullptr, nullptr);
break;
}
@ -2411,8 +2410,7 @@ nsXULPopupManager::HandleKeyboardEventWithKeyCode(
// Otherwise, tell the active menubar, if any, to activate the menu. The
// Enter method will return a menu if one needs to be opened as a result.
nsMenuFrame* menuToOpen = nullptr;
WidgetGUIEvent* GUIEvent = aKeyEvent->AsEvent()->
WidgetEventPtr()->AsGUIEvent();
WidgetGUIEvent* GUIEvent = aKeyEvent->WidgetEventPtr()->AsGUIEvent();
if (aTopVisibleMenuItem) {
menuToOpen = aTopVisibleMenuItem->Frame()->Enter(GUIEvent);
@ -2431,9 +2429,9 @@ nsXULPopupManager::HandleKeyboardEventWithKeyCode(
}
if (consume) {
aKeyEvent->AsEvent()->StopPropagation();
aKeyEvent->AsEvent()->StopCrossProcessForwarding();
aKeyEvent->AsEvent()->PreventDefault();
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
}
return true;
}
@ -2613,18 +2611,17 @@ nsXULPopupManager::IsValidMenuItem(nsIContent* aContent, bool aOnPopup)
nsresult
nsXULPopupManager::HandleEvent(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
RefPtr<KeyboardEvent> keyEvent =
aEvent->InternalDOMEvent()->AsKeyboardEvent();
NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
//handlers shouldn't be triggered by non-trusted events.
bool trustedEvent = false;
aEvent->GetIsTrusted(&trustedEvent);
if (!trustedEvent) {
if (!keyEvent->IsTrusted()) {
return NS_OK;
}
nsAutoString eventType;
aEvent->GetType(eventType);
keyEvent->GetType(eventType);
if (eventType.EqualsLiteral("keyup")) {
return KeyUp(keyEvent);
}
@ -2651,7 +2648,7 @@ nsXULPopupManager::UpdateIgnoreKeys(bool aIgnoreKeys)
}
nsresult
nsXULPopupManager::KeyUp(nsIDOMKeyEvent* aKeyEvent)
nsXULPopupManager::KeyUp(KeyboardEvent* aKeyEvent)
{
// don't do anything if a menu isn't open or a menubar isn't active
if (!mActiveMenuBar) {
@ -2660,20 +2657,20 @@ nsXULPopupManager::KeyUp(nsIDOMKeyEvent* aKeyEvent)
return NS_OK;
if (item->IgnoreKeys() == eIgnoreKeys_Shortcuts) {
aKeyEvent->AsEvent()->StopCrossProcessForwarding();
aKeyEvent->StopCrossProcessForwarding();
return NS_OK;
}
}
aKeyEvent->AsEvent()->StopPropagation();
aKeyEvent->AsEvent()->StopCrossProcessForwarding();
aKeyEvent->AsEvent()->PreventDefault();
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
return NS_OK; // I am consuming event
}
nsresult
nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
nsXULPopupManager::KeyDown(KeyboardEvent* aKeyEvent)
{
nsMenuChainItem* item = GetTopVisibleMenu();
if (item && item->Frame()->IsMenuLocked())
@ -2690,7 +2687,7 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
// Since a menu was open, stop propagation of the event to keep other event
// listeners from becoming confused.
if (!item || item->IgnoreKeys() != eIgnoreKeys_Shortcuts) {
aKeyEvent->AsEvent()->StopPropagation();
aKeyEvent->StopPropagation();
}
int32_t menuAccessKey = -1;
@ -2700,22 +2697,17 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
if (menuAccessKey) {
uint32_t theChar;
aKeyEvent->GetKeyCode(&theChar);
uint32_t theChar = aKeyEvent->KeyCode();
if (theChar == (uint32_t)menuAccessKey) {
bool ctrl = false;
if (menuAccessKey != nsIDOMKeyEvent::DOM_VK_CONTROL)
aKeyEvent->GetCtrlKey(&ctrl);
bool alt=false;
if (menuAccessKey != nsIDOMKeyEvent::DOM_VK_ALT)
aKeyEvent->GetAltKey(&alt);
bool shift=false;
if (menuAccessKey != nsIDOMKeyEvent::DOM_VK_SHIFT)
aKeyEvent->GetShiftKey(&shift);
bool meta=false;
if (menuAccessKey != nsIDOMKeyEvent::DOM_VK_META)
aKeyEvent->GetMetaKey(&meta);
bool ctrl = (menuAccessKey != nsIDOMKeyEvent::DOM_VK_CONTROL &&
aKeyEvent->CtrlKey());
bool alt = (menuAccessKey != nsIDOMKeyEvent::DOM_VK_ALT &&
aKeyEvent->AltKey());
bool shift = (menuAccessKey != nsIDOMKeyEvent::DOM_VK_SHIFT &&
aKeyEvent->ShiftKey());
bool meta = (menuAccessKey != nsIDOMKeyEvent::DOM_VK_META &&
aKeyEvent->MetaKey());
if (!(ctrl || alt || shift || meta)) {
// The access key just went down and no other
// modifiers are already down.
@ -2729,8 +2721,8 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
// Clear the item to avoid bugs as it may have been deleted during rollup.
item = nullptr;
}
aKeyEvent->AsEvent()->StopPropagation();
aKeyEvent->AsEvent()->PreventDefault();
aKeyEvent->StopPropagation();
aKeyEvent->PreventDefault();
}
}
@ -2739,7 +2731,7 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
}
nsresult
nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
nsXULPopupManager::KeyPress(KeyboardEvent* aKeyEvent)
{
// Don't check prevent default flag -- menus always get first shot at key events.
@ -2749,12 +2741,10 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
return NS_OK;
}
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED);
// if a menu is open or a menubar is active, it consumes the key event
bool consume = (item || mActiveMenuBar);
WidgetInputEvent* evt = aKeyEvent->AsEvent()->WidgetEventPtr()->AsInputEvent();
WidgetInputEvent* evt = aKeyEvent->WidgetEventPtr()->AsInputEvent();
bool isAccel = evt && evt->IsAccel();
// When ignorekeys="shortcuts" is used, we don't call preventDefault on the
@ -2765,12 +2755,12 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
consume = false;
}
HandleShortcutNavigation(keyEvent, nullptr);
HandleShortcutNavigation(aKeyEvent, nullptr);
aKeyEvent->AsEvent()->StopCrossProcessForwarding();
aKeyEvent->StopCrossProcessForwarding();
if (consume) {
aKeyEvent->AsEvent()->StopPropagation();
aKeyEvent->AsEvent()->PreventDefault();
aKeyEvent->StopPropagation();
aKeyEvent->PreventDefault();
}
return NS_OK; // I am consuming event

View File

@ -52,11 +52,16 @@ class nsMenuFrame;
class nsMenuPopupFrame;
class nsMenuBarFrame;
class nsMenuParent;
class nsIDOMKeyEvent;
class nsIDocShellTreeItem;
class nsPIDOMWindowOuter;
class nsRefreshDriver;
namespace mozilla {
namespace dom {
class KeyboardEvent;
} // namespace dom
} // namespace mozilla
// when a menu command is executed, the closemenu attribute may be used
// to define how the menu should be closed up
enum CloseMenuMode {
@ -670,7 +675,7 @@ public:
* key is handled by that popup, otherwise if aFrame is null, the key is
* handled by the active popup or menubar.
*/
bool HandleShortcutNavigation(nsIDOMKeyEvent* aKeyEvent,
bool HandleShortcutNavigation(mozilla::dom::KeyboardEvent* aKeyEvent,
nsMenuPopupFrame* aFrame);
/**
@ -694,15 +699,15 @@ public:
* Handles the keyboard event with keyCode value. Returns true if the event
* has been handled.
*/
bool HandleKeyboardEventWithKeyCode(nsIDOMKeyEvent* aKeyEvent,
bool HandleKeyboardEventWithKeyCode(mozilla::dom::KeyboardEvent* aKeyEvent,
nsMenuChainItem* aTopVisibleMenuItem);
// Sets mIgnoreKeys of the Top Visible Menu Item
nsresult UpdateIgnoreKeys(bool aIgnoreKeys);
nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyPress(nsIDOMKeyEvent* aKeyEvent);
nsresult KeyUp(mozilla::dom::KeyboardEvent* aKeyEvent);
nsresult KeyDown(mozilla::dom::KeyboardEvent* aKeyEvent);
nsresult KeyPress(mozilla::dom::KeyboardEvent* aKeyEvent);
protected:
nsXULPopupManager();