Back to index

lightning-sunbird  0.9+nobinonly
Enumerations | Functions
nsPrintPreviewListener.cpp File Reference
#include "nsPrintPreviewListener.h"
#include "nsIContent.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMNSEvent.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIDocShell.h"
#include "nsPresContext.h"
#include "nsIEventStateManager.h"
#include "nsLiteralString.h"

Go to the source code of this file.

Enumerations

enum  eEventAction { eEventAction_Tab, eEventAction_ShiftTab, eEventAction_Propagate, eEventAction_Suppress }

Functions

static eEventAction GetActionForEvent (nsIDOMEvent *aEvent)

Enumeration Type Documentation

Enumerator:
eEventAction_Tab 
eEventAction_ShiftTab 
eEventAction_Propagate 
eEventAction_Suppress 

Definition at line 121 of file nsPrintPreviewListener.cpp.


Function Documentation

static eEventAction GetActionForEvent ( nsIDOMEvent aEvent) [static]

Definition at line 127 of file nsPrintPreviewListener.cpp.

{
  static const PRUint32 kOKKeyCodes[] = {
    nsIDOMKeyEvent::DOM_VK_PAGE_UP, nsIDOMKeyEvent::DOM_VK_PAGE_DOWN,
    nsIDOMKeyEvent::DOM_VK_UP,      nsIDOMKeyEvent::DOM_VK_DOWN, 
    nsIDOMKeyEvent::DOM_VK_HOME,    nsIDOMKeyEvent::DOM_VK_END 
  };

  nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));
  if (keyEvent) {
    PRBool b;
    keyEvent->GetAltKey(&b);
    if (b) return eEventAction_Suppress;
    keyEvent->GetCtrlKey(&b);
    if (b) return eEventAction_Suppress;

    keyEvent->GetShiftKey(&b);

    PRUint32 keyCode;
    keyEvent->GetKeyCode(&keyCode);
    if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB)
      return b ? eEventAction_ShiftTab : eEventAction_Tab;

    PRUint32 charCode;
    keyEvent->GetCharCode(&charCode);
    if (charCode == ' ' || keyCode == nsIDOMKeyEvent::DOM_VK_SPACE)
      return eEventAction_Propagate;

    if (b) return eEventAction_Suppress;

    for (PRUint32 i = 0; i < sizeof(kOKKeyCodes)/sizeof(kOKKeyCodes[0]); ++i) {
      if (keyCode == kOKKeyCodes[i]) {
        return eEventAction_Propagate;
      }
    }
  }
  return eEventAction_Suppress;
}

Here is the call graph for this function: