Commit 4455f0fd authored by joki%netscape.com's avatar joki%netscape.com
Browse files

Fix for bug 108104, remaining part of fix from branch to keep user-created key...

Fix for bug 108104, remaining part of fix from branch to keep user-created key events from executing menu commands.  r:jst,mstoltz, sr:jst, a:asa
parent c0d70b7c
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include "nsIDOMNSUIEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsGUIEvent.h"
#include "nsIPrivateDOMEvent.h"                                                 

// Drag & Drop, Clipboard
#include "nsIServiceManager.h"
@@ -138,6 +139,17 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent)
{  
  InitAccessKey();

  //handlers shouldn't be triggered by non-trusted events.
  if (aKeyEvent) {
    nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
    if (privateEvent) {
      PRBool trustedEvent;
      privateEvent->IsTrustedEvent(&trustedEvent);
      if (!trustedEvent)
        return NS_OK;
    }
  }

  if (mAccessKey && mAccessKeyFocuses)
  {
    // On a press of the ALT key by itself, we toggle the menu's 
@@ -185,6 +197,17 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent)
      return NS_OK;       // don't consume event
  }

  //handlers shouldn't be triggered by non-trusted events.
  if (aKeyEvent) {
    nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
    if (privateEvent) {
      PRBool trustedEvent;
      privateEvent->IsTrustedEvent(&trustedEvent);
      if (!trustedEvent)
        return NS_OK;
    }
  }

  nsresult retVal = NS_OK;  // default is to not consume event
  
  InitAccessKey();
@@ -279,6 +302,17 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent)
{
  InitAccessKey();

  //handlers shouldn't be triggered by non-trusted events.
  if (aKeyEvent) {
    nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(aKeyEvent);
    if (privateEvent) {
      PRBool trustedEvent;
      privateEvent->IsTrustedEvent(&trustedEvent);
      if (!trustedEvent)
        return NS_OK;
    }
  }

  if (mAccessKey && mAccessKeyFocuses)
  {
    nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);