Bug 630811 part.1 Move modifiers from nsMouseEvent_base to nsInputEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 25 Apr 2012 12:00:02 +0900
changeset 96438 bf567dc0cd5be75cb5f54f9a86517a35039137c1
parent 96437 c4237652e91e9acd7bc8c80cb0663b706c679b59
child 96439 c3dfd5f664005cd7a4f33d15e5ab2ed35fb77bfc
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs630811
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 630811 part.1 Move modifiers from nsMouseEvent_base to nsInputEvent r=smaug
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMKeyboardEvent.cpp
content/events/src/nsDOMMouseEvent.cpp
content/events/src/nsDOMTouchEvent.cpp
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsDOMXULCommandEvent.cpp
widget/nsGUIEvent.h
widget/nsGUIEventIPC.h
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -691,17 +691,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
       NS_ENSURE_TRUE(mouseEvent, NS_ERROR_OUT_OF_MEMORY);
       isInputEvent = true;
       mouseEvent->clickCount = oldMouseEvent->clickCount;
       mouseEvent->acceptActivation = oldMouseEvent->acceptActivation;
       mouseEvent->context = oldMouseEvent->context;
       mouseEvent->relatedTarget = oldMouseEvent->relatedTarget;
       mouseEvent->button = oldMouseEvent->button;
       mouseEvent->buttons = oldMouseEvent->buttons;
-      mouseEvent->modifiers = oldMouseEvent->modifiers;
       mouseEvent->pressure = oldMouseEvent->pressure;
       mouseEvent->inputSource = oldMouseEvent->inputSource;
       newEvent = mouseEvent;
       break;
     }
     case NS_DRAG_EVENT:
     {
       nsDragEvent* oldDragEvent = static_cast<nsDragEvent*>(mEvent);
@@ -710,17 +709,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
       NS_ENSURE_TRUE(dragEvent, NS_ERROR_OUT_OF_MEMORY);
       isInputEvent = true;
       dragEvent->dataTransfer = oldDragEvent->dataTransfer;
       dragEvent->clickCount = oldDragEvent->clickCount;
       dragEvent->acceptActivation = oldDragEvent->acceptActivation;
       dragEvent->relatedTarget = oldDragEvent->relatedTarget;
       dragEvent->button = oldDragEvent->button;
       dragEvent->buttons = oldDragEvent->buttons;
-      dragEvent->modifiers = oldDragEvent->modifiers;
       static_cast<nsMouseEvent*>(dragEvent)->inputSource =
         static_cast<nsMouseEvent*>(oldDragEvent)->inputSource;
       newEvent = dragEvent;
       break;
     }
     case NS_SCRIPT_ERROR_EVENT:
     {
       newEvent = new nsScriptErrorEvent(false, msg);
@@ -753,17 +751,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
       isInputEvent = true;
       nsMouseScrollEvent* oldMouseScrollEvent =
         static_cast<nsMouseScrollEvent*>(mEvent);
       mouseScrollEvent->scrollFlags = oldMouseScrollEvent->scrollFlags;
       mouseScrollEvent->delta = oldMouseScrollEvent->delta;
       mouseScrollEvent->relatedTarget = oldMouseScrollEvent->relatedTarget;
       mouseScrollEvent->button = oldMouseScrollEvent->button;
       mouseScrollEvent->buttons = oldMouseScrollEvent->buttons;
-      mouseScrollEvent->modifiers = oldMouseScrollEvent->modifiers;
       static_cast<nsMouseEvent_base*>(mouseScrollEvent)->inputSource =
         static_cast<nsMouseEvent_base*>(oldMouseScrollEvent)->inputSource;
       newEvent = mouseScrollEvent;
       break;
     }
     case NS_SCROLLPORT_EVENT:
     {
       newEvent = new nsScrollPortEvent(false, msg, nsnull);
@@ -864,17 +861,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
     }
     case NS_SIMPLE_GESTURE_EVENT:
     {
       nsSimpleGestureEvent* oldSimpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent);
       nsSimpleGestureEvent* simpleGestureEvent = 
         new nsSimpleGestureEvent(false, msg, nsnull, 0, 0.0);
       NS_ENSURE_TRUE(simpleGestureEvent, NS_ERROR_OUT_OF_MEMORY);
       isInputEvent = true;
-      simpleGestureEvent->modifiers = oldSimpleGestureEvent->modifiers;
       simpleGestureEvent->direction = oldSimpleGestureEvent->direction;
       simpleGestureEvent->delta = oldSimpleGestureEvent->delta;
       newEvent = simpleGestureEvent;
       break;
     }
     case NS_TRANSITION_EVENT:
     {
       nsTransitionEvent* oldTransitionEvent =
@@ -898,17 +894,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
     case NS_MOZTOUCH_EVENT:
     {
       nsMozTouchEvent* oldMozTouchEvent = static_cast<nsMozTouchEvent*>(mEvent);
       nsMozTouchEvent* mozTouchEvent =
         new nsMozTouchEvent(false, msg, nsnull,
                             static_cast<nsMozTouchEvent*>(mEvent)->streamId);
       NS_ENSURE_TRUE(mozTouchEvent, NS_ERROR_OUT_OF_MEMORY);
       isInputEvent = true;
-      mozTouchEvent->modifiers = oldMozTouchEvent->modifiers;
       mozTouchEvent->buttons = oldMozTouchEvent->buttons;
       newEvent = mozTouchEvent;
       break;
     }
     case NS_TOUCH_EVENT:
     {
       nsTouchEvent *oldTouchEvent = static_cast<nsTouchEvent*>(mEvent);
       newEvent = new nsTouchEvent(false, oldTouchEvent);
@@ -923,20 +918,17 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
     }
   }
 
   NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
 
   if (isInputEvent) {
     nsInputEvent* oldInputEvent = static_cast<nsInputEvent*>(mEvent);
     nsInputEvent* newInputEvent = static_cast<nsInputEvent*>(newEvent);
-    newInputEvent->isShift = oldInputEvent->isShift;
-    newInputEvent->isControl = oldInputEvent->isControl;
-    newInputEvent->isAlt = oldInputEvent->isAlt;
-    newInputEvent->isMeta = oldInputEvent->isMeta;
+    newInputEvent->modifiers = oldInputEvent->modifiers;
   }
 
   newEvent->target                 = mEvent->target;
   newEvent->currentTarget          = mEvent->currentTarget;
   newEvent->originalTarget         = mEvent->originalTarget;
   newEvent->flags                  = mEvent->flags;
   newEvent->time                   = mEvent->time;
   newEvent->refPoint               = mEvent->refPoint;
--- a/content/events/src/nsDOMKeyboardEvent.cpp
+++ b/content/events/src/nsDOMKeyboardEvent.cpp
@@ -73,41 +73,41 @@ NS_INTERFACE_MAP_BEGIN(nsDOMKeyboardEven
   NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(KeyboardEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isAlt;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsAlt();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isControl;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsControl();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isShift;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsShift();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isMeta;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsMeta();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::GetCharCode(PRUint32* aCharCode)
 {
   NS_ENSURE_ARG_POINTER(aCharCode);
 
@@ -179,20 +179,17 @@ nsDOMKeyboardEvent::InitKeyEvent(const n
                                  nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
                                  bool aShiftKey, bool aMetaKey,
                                  PRUint32 aKeyCode, PRUint32 aCharCode)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsKeyEvent* keyEvent = static_cast<nsKeyEvent*>(mEvent);
-  keyEvent->isControl = aCtrlKey;
-  keyEvent->isAlt = aAltKey;
-  keyEvent->isShift = aShiftKey;
-  keyEvent->isMeta = aMetaKey;
+  keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
   keyEvent->keyCode = aKeyCode;
   keyEvent->charCode = aCharCode;
 
   return NS_OK;
 }
 
 nsresult NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
                                 nsPresContext* aPresContext,
--- a/content/events/src/nsDOMMouseEvent.cpp
+++ b/content/events/src/nsDOMMouseEvent.cpp
@@ -120,20 +120,17 @@ nsDOMMouseEvent::InitMouseEvent(const ns
     case NS_MOUSE_SCROLL_EVENT:
     case NS_DRAG_EVENT:
     case NS_SIMPLE_GESTURE_EVENT:
     case NS_MOZTOUCH_EVENT:
     {
        static_cast<nsMouseEvent_base*>(mEvent)->relatedTarget = aRelatedTarget;
        static_cast<nsMouseEvent_base*>(mEvent)->button = aButton;
        nsInputEvent* inputEvent = static_cast<nsInputEvent*>(mEvent);
-       inputEvent->isControl = aCtrlKey;
-       inputEvent->isAlt = aAltKey;
-       inputEvent->isShift = aShiftKey;
-       inputEvent->isMeta = aMetaKey;
+       inputEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
        mClientPoint.x = aClientX;
        mClientPoint.y = aClientY;
        inputEvent->refPoint.x = aScreenX;
        inputEvent->refPoint.y = aScreenY;
 
        if (mEvent->eventStructType == NS_MOUSE_EVENT) {
          nsMouseEvent* mouseEvent = static_cast<nsMouseEvent*>(mEvent);
          mouseEvent->clickCount = aDetail;
@@ -173,17 +170,17 @@ nsDOMMouseEvent::InitMouseEvent(const ns
   NS_ENSURE_SUCCESS(rv, rv);
 
   switch(mEvent->eventStructType) {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_DRAG_EVENT:
     case NS_SIMPLE_GESTURE_EVENT:
     case NS_MOZTOUCH_EVENT:
-      static_cast<nsMouseEvent_base*>(mEvent)->modifiers = modifiers;
+      static_cast<nsInputEvent*>(mEvent)->modifiers = modifiers;
       return NS_OK;
     default:
       MOZ_NOT_REACHED("There is no space to store the modifiers");
       return NS_ERROR_FAILURE;
   }
 }
 
 nsresult
@@ -368,41 +365,41 @@ nsDOMMouseEvent::GetClientY(PRInt32* aCl
                                           mClientPoint).y;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isAlt;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsAlt();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isControl;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsControl();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isShift;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsShift();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ((nsInputEvent*)mEvent)->isMeta;
+  *aIsDown = static_cast<nsInputEvent*>(mEvent)->IsMeta();
   return NS_OK;
 }
 
 /* virtual */
 nsresult
 nsDOMMouseEvent::Which(PRUint32* aWhich)
 {
   NS_ENSURE_ARG_POINTER(aWhich);
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -286,20 +286,18 @@ nsDOMTouchEvent::InitTouchEvent(const ns
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType,
                                           aCanBubble,
                                           aCancelable,
                                           aView,
                                           aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  static_cast<nsInputEvent*>(mEvent)->isControl = aCtrlKey;
-  static_cast<nsInputEvent*>(mEvent)->isAlt = aAltKey;
-  static_cast<nsInputEvent*>(mEvent)->isShift = aShiftKey;
-  static_cast<nsInputEvent*>(mEvent)->isMeta = aMetaKey;
+  static_cast<nsInputEvent*>(mEvent)->InitBasicModifiers(aCtrlKey, aAltKey,
+                                                         aShiftKey, aMetaKey);
   mTouches = aTouches;
   mTargetTouches = aTargetTouches;
   mChangedTouches = aChangedTouches;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTouchEvent::GetTouches(nsIDOMTouchList** aTouches)
@@ -378,38 +376,38 @@ nsDOMTouchEvent::GetChangedTouches(nsIDO
   }
   mChangedTouches = new nsDOMTouchList(changedTouches);
   return CallQueryInterface(mChangedTouches, aChangedTouches);
 }
 
 NS_IMETHODIMP
 nsDOMTouchEvent::GetAltKey(bool* aAltKey)
 {
-  *aAltKey = static_cast<nsInputEvent*>(mEvent)->isAlt;
+  *aAltKey = static_cast<nsInputEvent*>(mEvent)->IsAlt();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTouchEvent::GetMetaKey(bool* aMetaKey)
 {
-  *aMetaKey = static_cast<nsInputEvent*>(mEvent)->isMeta;
+  *aMetaKey = static_cast<nsInputEvent*>(mEvent)->IsMeta();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTouchEvent::GetCtrlKey(bool* aCtrlKey)
 {
-  *aCtrlKey = static_cast<nsInputEvent*>(mEvent)->isControl;
+  *aCtrlKey = static_cast<nsInputEvent*>(mEvent)->IsControl();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTouchEvent::GetShiftKey(bool* aShiftKey)
 {
-  *aShiftKey = static_cast<nsInputEvent*>(mEvent)->isShift;
+  *aShiftKey = static_cast<nsInputEvent*>(mEvent)->IsShift();
   return NS_OK;
 }
 
 bool
 nsDOMTouchEvent::PrefEnabled()
 {
   static bool sDidCheckPref = false;
   static bool sPrefValue = false;
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -505,66 +505,52 @@ nsDOMUIEvent::ComputeModifierState(const
   }
 
   return modifiers;
 }
 
 bool
 nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
 {
-  mozilla::widget::Modifiers modifiers = 0;
-  switch(mEvent->eventStructType) {
-    case NS_MOUSE_EVENT:
-    case NS_MOUSE_SCROLL_EVENT:
-    case NS_DRAG_EVENT:
-    case NS_SIMPLE_GESTURE_EVENT:
-    case NS_MOZTOUCH_EVENT:
-      modifiers = static_cast<nsMouseEvent_base*>(mEvent)->modifiers;
-      break;
-    default:
-      MOZ_NOT_REACHED("There is no space to store the modifiers");
-      return false;
-  }
-
+  nsInputEvent* inputEvent = static_cast<nsInputEvent*>(mEvent);
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) {
-    return static_cast<nsInputEvent*>(mEvent)->isShift;
+    return inputEvent->IsShift();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CONTROL)) {
-    return static_cast<nsInputEvent*>(mEvent)->isControl;
+    return inputEvent->IsControl();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_META)) {
-    return static_cast<nsInputEvent*>(mEvent)->isMeta;
+    return inputEvent->IsMeta();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALT)) {
-    return static_cast<nsInputEvent*>(mEvent)->isAlt;
+    return inputEvent->IsAlt();
   }
 
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALTGRAPH)) {
-    return (modifiers & widget::MODIFIER_ALTGRAPH) != 0;
+    return inputEvent->IsAltGraph();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_WIN)) {
-    return (modifiers & widget::MODIFIER_WIN) != 0;
+    return inputEvent->IsWin();
   }
 
-
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CAPSLOCK)) {
-    return (modifiers & widget::MODIFIER_CAPSLOCK) != 0;
+    return inputEvent->IsCapsLocked();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_NUMLOCK)) {
-    return (modifiers & widget::MODIFIER_NUMLOCK) != 0;
+    return inputEvent->IsNumLocked();
   }
 
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_FN)) {
-    return (modifiers & widget::MODIFIER_FN) != 0;
+    return inputEvent->IsFn();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SCROLL)) {
-    return (modifiers & widget::MODIFIER_SCROLL) != 0;
+    return inputEvent->IsScrollLocked();
   }
   if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SYMBOLLOCK)) {
-    return (modifiers & widget::MODIFIER_SYMBOLLOCK) != 0;
+    return inputEvent->IsSymbolLocked();
   }
   return false;
 }
 
 
 nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
                           nsPresContext* aPresContext,
                           nsGUIEvent *aEvent) 
--- a/content/events/src/nsDOMXULCommandEvent.cpp
+++ b/content/events/src/nsDOMXULCommandEvent.cpp
@@ -74,41 +74,41 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
   NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULCommandEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 NS_IMETHODIMP
 nsDOMXULCommandEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = Event()->isAlt;
+  *aIsDown = Event()->IsAlt();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMXULCommandEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = Event()->isControl;
+  *aIsDown = Event()->IsControl();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMXULCommandEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = Event()->isShift;
+  *aIsDown = Event()->IsShift();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMXULCommandEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = Event()->isMeta;
+  *aIsDown = Event()->IsMeta();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
 {
   NS_ENSURE_ARG_POINTER(aSourceEvent);
   NS_IF_ADDREF(*aSourceEvent = mSourceEvent);
@@ -123,21 +123,17 @@ nsDOMXULCommandEvent::InitCommandEvent(c
                                        bool aCtrlKey, bool aAltKey,
                                        bool aShiftKey, bool aMetaKey,
                                        nsIDOMEvent* aSourceEvent)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
                                           aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsInputEvent *event = Event();
-  event->isControl = aCtrlKey;
-  event->isAlt = aAltKey;
-  event->isShift = aShiftKey;
-  event->isMeta = aMetaKey;
+  Event()->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
   mSourceEvent = aSourceEvent;
 
   return NS_OK;
 }
 
 
 nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
                                   nsPresContext* aPresContext,
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -816,39 +816,112 @@ public:
 };
 
 class nsInputEvent : public nsGUIEvent
 {
 protected:
   nsInputEvent(bool isTrusted, PRUint32 msg, nsIWidget *w,
                PRUint8 structType)
     : nsGUIEvent(isTrusted, msg, w, structType),
-      isShift(false), isControl(false), isAlt(false), isMeta(false)
+      modifiers(0)
   {
   }
 
   nsInputEvent()
   {
   }
 
 public:
   nsInputEvent(bool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
-      isShift(false), isControl(false), isAlt(false), isMeta(false)
+      modifiers(0)
   {
   }
 
-  /// true indicates the shift key is down
-  bool            isShift;        
-  /// true indicates the control key is down
-  bool            isControl;      
-  /// true indicates the alt key is down
-  bool            isAlt;          
-  /// true indicates the meta key is down (or, on Mac, the Command key)
-  bool            isMeta;
+  // true indicates the shift key is down
+  bool IsShift() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_SHIFT) != 0);
+  }
+  // true indicates the control key is down
+  bool IsControl() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_CONTROL) != 0);
+  }
+  // true indicates the alt key is down
+  bool IsAlt() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_ALT) != 0);
+  }
+  // true indicates the meta key is down (or, on Mac, the Command key)
+  bool IsMeta() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_META) != 0);
+  }
+  // true indicates the win key is down (or, on Linux, the Super or Hyper key)
+  bool IsWin() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_WIN) != 0);
+  }
+  // true indicates the alt graph key is down
+  // NOTE: on Mac, the option key press causes both IsAlt() and IsAltGrpah()
+  //       return true.
+  bool IsAltGraph() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_ALTGRAPH) != 0);
+  }
+  // true indeicates the CapLock LED is turn on.
+  bool IsCapsLocked() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_CAPSLOCK) != 0);
+  }
+  // true indeicates the NumLock LED is turn on.
+  bool IsNumLocked() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_NUMLOCK) != 0);
+  }
+  // true indeicates the ScrollLock LED is turn on.
+  bool IsScrollLocked() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_SCROLL) != 0);
+  }
+
+  // true indeicates the Fn key is down, but this is not supported by native
+  // key event on any platform.
+  bool IsFn() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_FN) != 0);
+  }
+  // true indeicates the ScrollLock LED is turn on.
+  bool IsSymbolLocked() const
+  {
+    return ((modifiers & mozilla::widget::MODIFIER_SYMBOLLOCK) != 0);
+  }
+
+  void InitBasicModifiers(bool aCtrlKey,
+                          bool aAltKey,
+                          bool aShiftKey,
+                          bool aMetaKey)
+  {
+    modifiers = 0;
+    if (aCtrlKey) {
+      modifiers |= mozilla::widget::MODIFIER_CONTROL;
+    }
+    if (aAltKey) {
+      modifiers |= mozilla::widget::MODIFIER_ALT;
+    }
+    if (aShiftKey) {
+      modifiers |= mozilla::widget::MODIFIER_SHIFT;
+    }
+    if (aMetaKey) {
+      modifiers |= mozilla::widget::MODIFIER_META;
+    }
+  }
+
+  mozilla::widget::Modifiers modifiers;
 };
 
 /**
  * Mouse event
  */
 
 class nsMouseEvent_base : public nsInputEvent
 {
@@ -859,25 +932,23 @@ private:
 public:
 
   nsMouseEvent_base()
   {
   }
 
   nsMouseEvent_base(bool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 type)
     : nsInputEvent(isTrusted, msg, w, type), button(0), buttons(0),
-      modifiers(0), pressure(0),
-      inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {}
+      pressure(0), inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {}
 
   /// The possible related target
   nsCOMPtr<nsISupports> relatedTarget;
 
   PRInt16               button;
   PRInt16               buttons;
-  mozilla::widget::Modifiers modifiers;
 
   // Finger or touch pressure of event
   // ranges between 0.0 and 1.0
   float                 pressure;
 
   // Possible values at nsIDOMMouseEvent
   PRUint16              inputSource;
 };
@@ -1570,20 +1641,17 @@ class nsTouchEvent : public nsInputEvent
 {
 public:
   nsTouchEvent(bool isTrusted, nsTouchEvent *aEvent)
     : nsInputEvent(isTrusted,
                    aEvent->message,
                    aEvent->widget,
                    NS_TOUCH_EVENT)
   {
-    isShift = aEvent->isShift;
-    isControl = aEvent->isControl;
-    isMeta = aEvent->isMeta;
-    isAlt = aEvent->isAlt;
+    modifiers = aEvent->modifiers;
     time = aEvent->time;
     touches.AppendElements(aEvent->touches);
     MOZ_COUNT_CTOR(nsTouchEvent);
   }
   nsTouchEvent(bool isTrusted, PRUint32 msg, nsIWidget* w)
     : nsInputEvent(isTrusted, msg, w, NS_TOUCH_EVENT)
   {
     MOZ_COUNT_CTOR(nsTouchEvent);
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -88,53 +88,45 @@ struct ParamTraits<nsGUIEvent>
 template<>
 struct ParamTraits<nsInputEvent>
 {
   typedef nsInputEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<nsGUIEvent>(aParam));
-    WriteParam(aMsg, aParam.isShift);
-    WriteParam(aMsg, aParam.isControl);
-    WriteParam(aMsg, aParam.isAlt);
-    WriteParam(aMsg, aParam.isMeta);
+    WriteParam(aMsg, aParam.modifiers);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     return ReadParam(aMsg, aIter, static_cast<nsGUIEvent*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->isShift) &&
-           ReadParam(aMsg, aIter, &aResult->isControl) &&
-           ReadParam(aMsg, aIter, &aResult->isAlt) &&
-           ReadParam(aMsg, aIter, &aResult->isMeta);
+           ReadParam(aMsg, aIter, &aResult->modifiers);
   }
 };
 
 template<>
 struct ParamTraits<nsMouseEvent_base>
 {
   typedef nsMouseEvent_base paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<nsInputEvent>(aParam));
     WriteParam(aMsg, aParam.button);
     WriteParam(aMsg, aParam.buttons);
-    WriteParam(aMsg, aParam.modifiers);
     WriteParam(aMsg, aParam.pressure);
     WriteParam(aMsg, aParam.inputSource);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     return ReadParam(aMsg, aIter, static_cast<nsInputEvent*>(aResult)) &&
            ReadParam(aMsg, aIter, &aResult->button) &&
            ReadParam(aMsg, aIter, &aResult->buttons) &&
-           ReadParam(aMsg, aIter, &aResult->modifiers) &&
            ReadParam(aMsg, aIter, &aResult->pressure) &&
            ReadParam(aMsg, aIter, &aResult->inputSource);
   }
 };
 
 template<>
 struct ParamTraits<nsMouseScrollEvent>
 {