Bug 1436508 part 8. Remove unused nsIDOMKeyEvent members. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 09 Feb 2018 11:17:09 -0500
changeset 403180 745e6034684b
parent 403179 ee44459b72f6
child 403181 498d0e9ef3da
push id33416
push userarchaeopteryx@coole-files.de
push date2018-02-09 22:32 +0000
treeherdermozilla-central@c2cddb0cbb20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1436508
milestone60.0a1
Bug 1436508 part 8. Remove unused nsIDOMKeyEvent members. r=masayuki MozReview-Commit-ID: 57xpY8vNfW2
dom/events/KeyboardEvent.cpp
dom/events/KeyboardEvent.h
dom/interfaces/events/nsIDOMKeyEvent.idl
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -48,115 +48,64 @@ KeyboardEvent::AltKey(CallerType aCaller
   }
 
   // We need to give a spoofed state for Alt key since it could be used as a
   // modifier key in certain keyboard layout. For example, the '@' key for
   // German keyboard for MAC is Alt+L.
   return GetSpoofedModifierStates(Modifier::MODIFIER_ALT, altState);
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetAltKey(bool* aIsDown)
-{
-  NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = AltKey();
-  return NS_OK;
-}
-
 bool
 KeyboardEvent::CtrlKey(CallerType aCallerType)
 {
   bool ctrlState = mEvent->AsKeyboardEvent()->IsControl();
 
   if (!ShouldResistFingerprinting(aCallerType)) {
     return ctrlState;
   }
 
   // We need to give a spoofed state for Control key since it could be used as a
   // modifier key in certain asian keyboard layouts.
   return GetSpoofedModifierStates(Modifier::MODIFIER_CONTROL, ctrlState);
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetCtrlKey(bool* aIsDown)
-{
-  NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = CtrlKey();
-  return NS_OK;
-}
-
 bool
 KeyboardEvent::ShiftKey(CallerType aCallerType)
 {
   bool shiftState = mEvent->AsKeyboardEvent()->IsShift();
 
   if (!ShouldResistFingerprinting(aCallerType)) {
     return shiftState;
   }
 
   return GetSpoofedModifierStates(Modifier::MODIFIER_SHIFT, shiftState);
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetShiftKey(bool* aIsDown)
-{
-  NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = ShiftKey();
-  return NS_OK;
-}
-
 bool
 KeyboardEvent::MetaKey()
 {
   return mEvent->AsKeyboardEvent()->IsMeta();
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetMetaKey(bool* aIsDown)
-{
-  NS_ENSURE_ARG_POINTER(aIsDown);
-  *aIsDown = MetaKey();
-  return NS_OK;
-}
-
 bool
 KeyboardEvent::Repeat()
 {
   return mEvent->AsKeyboardEvent()->mIsRepeat;
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetRepeat(bool* aIsRepeat)
-{
-  NS_ENSURE_ARG_POINTER(aIsRepeat);
-  *aIsRepeat = Repeat();
-  return NS_OK;
-}
-
 bool
 KeyboardEvent::IsComposing()
 {
   return mEvent->AsKeyboardEvent()->mIsComposing;
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetModifierState(const nsAString& aKey,
-                                bool* aState)
-{
-  NS_ENSURE_ARG_POINTER(aState);
-
-  *aState = GetModifierState(aKey);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-KeyboardEvent::GetKey(nsAString& aKeyName)
+void
+KeyboardEvent::GetKey(nsAString& aKeyName) const
 {
   mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
-  return NS_OK;
 }
 
 void
 KeyboardEvent::GetCode(nsAString& aCodeName, CallerType aCallerType)
 {
   if (!ShouldResistFingerprinting(aCallerType)) {
     mEvent->AsKeyboardEvent()->GetDOMCodeName(aCodeName);
     return;
@@ -200,24 +149,16 @@ void KeyboardEvent::GetInitDict(Keyboard
   aParam.mModifierSymbol = internalEvent->IsSymbol();
   aParam.mModifierSymbolLock = internalEvent->IsSymbolLocked();
 
   // EventInit
   aParam.mBubbles =  internalEvent->mFlags.mBubbles;
   aParam.mCancelable = internalEvent->mFlags.mCancelable;
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetCharCode(uint32_t* aCharCode)
-{
-  NS_ENSURE_ARG_POINTER(aCharCode);
-  *aCharCode = CharCode();
-  return NS_OK;
-}
-
 uint32_t
 KeyboardEvent::CharCode()
 {
   // If this event is initialized with ctor, we shouldn't check event type.
   if (mInitializedByCtor) {
     return mEvent->AsKeyboardEvent()->mCharCode;
   }
 
@@ -231,24 +172,16 @@ KeyboardEvent::CharCode()
   case eAccessKeyNotFound:
     return mEvent->AsKeyboardEvent()->mCharCode;
   default:
     break;
   }
   return 0;
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
-{
-  NS_ENSURE_ARG_POINTER(aKeyCode);
-  *aKeyCode = KeyCode();
-  return NS_OK;
-}
-
 uint32_t
 KeyboardEvent::KeyCode(CallerType aCallerType)
 {
   // If this event is initialized with ctor, we shouldn't check event type.
   if (mInitializedByCtor) {
     return mEvent->AsKeyboardEvent()->mKeyCode;
   }
 
@@ -304,25 +237,16 @@ KeyboardEvent::Which()
       }
     default:
       break;
   }
 
   return 0;
 }
 
-NS_IMETHODIMP
-KeyboardEvent::GetLocation(uint32_t* aLocation)
-{
-  NS_ENSURE_ARG_POINTER(aLocation);
-
-  *aLocation = Location();
-  return NS_OK;
-}
-
 uint32_t
 KeyboardEvent::Location()
 {
   return mEvent->AsKeyboardEvent()->mLocation;
 }
 
 // static
 already_AddRefed<KeyboardEvent>
@@ -366,38 +290,31 @@ KeyboardEvent::InitWithKeyboardEventInit
   }
   internalEvent->mCodeNameIndex =
     WidgetKeyboardEvent::GetCodeNameIndex(aParam.mCode);
   if (internalEvent->mCodeNameIndex == CODE_NAME_INDEX_USE_STRING) {
     internalEvent->mCodeValue = aParam.mCode;
   }
 }
 
-NS_IMETHODIMP
-KeyboardEvent::InitKeyEvent(const nsAString& aType,
-                            bool aCanBubble,
-                            bool aCancelable,
-                            mozIDOMWindow* aView,
-                            bool aCtrlKey,
-                            bool aAltKey,
-                            bool aShiftKey,
-                            bool aMetaKey,
-                            uint32_t aKeyCode,
-                            uint32_t aCharCode)
+void
+KeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble,
+                            bool aCancelable, nsGlobalWindowInner* aView,
+                            bool aCtrlKey, bool aAltKey,
+                            bool aShiftKey, bool aMetaKey,
+                            uint32_t aKeyCode, uint32_t aCharCode)
 {
-  NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
+  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
 
   UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
 
   WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
   keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
   keyEvent->mKeyCode = aKeyCode;
   keyEvent->mCharCode = aCharCode;
-
-  return NS_OK;
 }
 
 void
 KeyboardEvent::InitKeyboardEvent(const nsAString& aType,
                                  bool aCanBubble,
                                  bool aCancelable,
                                  nsGlobalWindowInner* aView,
                                  const nsAString& aKey,
--- a/dom/events/KeyboardEvent.h
+++ b/dom/events/KeyboardEvent.h
@@ -65,33 +65,29 @@ public:
     }
 
     Modifiers modifier = WidgetInputEvent::GetModifier(aKey);
     return GetSpoofedModifierStates(modifier, modifierState);
   }
 
   bool Repeat();
   bool IsComposing();
+  void GetKey(nsAString& aKey) const;
   uint32_t CharCode();
   uint32_t KeyCode(CallerType aCallerType = CallerType::System);
   virtual uint32_t Which() override;
   uint32_t Location();
 
   void GetCode(nsAString& aCode, CallerType aCallerType = CallerType::System);
   void GetInitDict(KeyboardEventInit& aParam);
 
   void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                     nsGlobalWindowInner* aView, bool aCtrlKey, bool aAltKey,
                     bool aShiftKey, bool aMetaKey,
-                    uint32_t aKeyCode, uint32_t aCharCode)
-  {
-    auto* view = aView ? aView->AsInner() : nullptr;
-    InitKeyEvent(aType, aCanBubble, aCancelable, view, aCtrlKey, aAltKey,
-                 aShiftKey, aMetaKey, aKeyCode, aCharCode);
-  }
+                    uint32_t aKeyCode, uint32_t aCharCode);
 
   void InitKeyboardEvent(const nsAString& aType,
                          bool aCanBubble, bool aCancelable,
                          nsGlobalWindowInner* aView, const nsAString& aKey,
                          uint32_t aLocation, bool aCtrlKey, bool aAltKey,
                          bool aShiftKey, bool aMetaKey, ErrorResult& aRv);
 
 protected:
--- a/dom/interfaces/events/nsIDOMKeyEvent.idl
+++ b/dom/interfaces/events/nsIDOMKeyEvent.idl
@@ -220,39 +220,13 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
   const unsigned long DOM_VK_PLAY           = 0xFA;
   const unsigned long DOM_VK_ZOOM           = 0xFB;
   const unsigned long DOM_VK_PA1            = 0xFD;
 
   // OEM specific virtual keyCode of Windows should pass through DOM keyCode
   // for compatibility with the other web browsers on Windows.
   const unsigned long DOM_VK_WIN_OEM_CLEAR  = 0xFE;
 
-  readonly attribute unsigned long    charCode;
-  readonly attribute unsigned long    keyCode;
-
-  readonly attribute boolean          altKey;
-  readonly attribute boolean          ctrlKey;
-  readonly attribute boolean          shiftKey;
-  readonly attribute boolean          metaKey;
-
-  void                      initKeyEvent(in DOMString typeArg,
-                                         in boolean canBubbleArg,
-                                         in boolean cancelableArg,
-                                         in mozIDOMWindow viewArg,
-                                         in boolean ctrlKeyArg,
-                                         in boolean altKeyArg,
-                                         in boolean shiftKeyArg,
-                                         in boolean metaKeyArg,
-                                         in unsigned long keyCodeArg,
-                                         in unsigned long charCodeArg);
-
-  bool getModifierState(in DOMString keyArg);
-
   const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;
   const unsigned long DOM_KEY_LOCATION_LEFT     = 0x01;
   const unsigned long DOM_KEY_LOCATION_RIGHT    = 0x02;
   const unsigned long DOM_KEY_LOCATION_NUMPAD   = 0x03;
-
-  readonly attribute unsigned long location;
-  readonly attribute boolean       repeat;
-
-  readonly attribute DOMString key;
 };