Bug 866436 - Cleanup the implementation of UIEvent.which; r=smaug

This commit is contained in:
Ms2ger 2013-05-05 09:03:16 +02:00
parent a60820e813
commit e4191ddfb4
6 changed files with 9 additions and 43 deletions

View File

@ -134,15 +134,6 @@ nsDOMKeyboardEvent::KeyCode()
return 0;
}
/* virtual */
nsresult
nsDOMKeyboardEvent::Which(uint32_t* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
*aWhich = Which();
return NS_OK;
}
uint32_t
nsDOMKeyboardEvent::Which()
{

View File

@ -76,10 +76,6 @@ public:
aCtrlKey, aAltKey, aShiftKey,aMetaKey,
aKeyCode, aCharCode);
}
protected:
// Specific implementation for a keyboard event.
virtual nsresult Which(uint32_t* aWhich);
};

View File

@ -447,17 +447,6 @@ nsDOMMouseEvent::GetModifierState(const nsAString& aKey,
return NS_OK;
}
/* virtual */
nsresult
nsDOMMouseEvent::Which(uint32_t* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
uint16_t button;
(void) GetButton(&button);
*aWhich = button + 1;
return NS_OK;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetMozPressure(float* aPressure)
{

View File

@ -40,9 +40,7 @@ public:
// Web IDL binding methods
virtual uint32_t Which() MOZ_OVERRIDE
{
uint32_t w = 0;
Which(&w);
return w;
return Button() + 1;
}
int32_t ScreenX();
@ -123,9 +121,6 @@ public:
}
protected:
// Specific implementation for a mouse event.
virtual nsresult Which(uint32_t* aWhich);
nsresult InitMouseEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,

View File

@ -253,7 +253,9 @@ nsDOMUIEvent::GetPageY(int32_t* aPageY)
NS_IMETHODIMP
nsDOMUIEvent::GetWhich(uint32_t* aWhich)
{
return Which(aWhich);
NS_ENSURE_ARG_POINTER(aWhich);
*aWhich = Which();
return NS_OK;
}
already_AddRefed<nsINode>

View File

@ -135,9 +135,11 @@ public:
virtual uint32_t Which()
{
uint32_t w;
GetWhich(&w);
return w;
MOZ_ASSERT(mEvent->eventStructType != NS_KEY_EVENT,
"Key events should override Which()");
MOZ_ASSERT(mEvent->eventStructType != NS_MOUSE_EVENT,
"Mouse events should override Which()");
return 0;
}
already_AddRefed<nsINode> GetRangeParent();
@ -168,15 +170,6 @@ protected:
nsIntPoint GetLayerPoint();
nsIntPoint GetPagePoint();
// Allow specializations.
virtual nsresult Which(uint32_t* aWhich)
{
NS_ENSURE_ARG_POINTER(aWhich);
// Usually we never reach here, as this is reimplemented for mouse and keyboard events.
*aWhich = 0;
return NS_OK;
}
nsCOMPtr<nsIDOMWindow> mView;
int32_t mDetail;
nsIntPoint mClientPoint;