Bug 1211365 - Remove NS_IMPL_STATE_UTILITIES. r=mtseng

This macro was used to implement Name() and Singleton() for state
classes. Instead of enforcing the state class to be a singleton, we can
implement singleton pattern in MOZ_IMPL_STATE_CLASS_GETTER directly.
This commit is contained in:
Ting-Yu Lin 2015-10-05 16:52:29 +08:00
parent 503485e5c4
commit 691897a897
2 changed files with 9 additions and 16 deletions

View File

@ -40,7 +40,7 @@ class AccessibleCaretEventHub::NoActionState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(NoActionState)
virtual const char* Name() const override { return "NoActionState"; }
virtual nsEventStatus OnPress(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint,
@ -104,7 +104,7 @@ class AccessibleCaretEventHub::PressCaretState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(PressCaretState)
virtual const char* Name() const override { return "PressCaretState"; }
virtual nsEventStatus OnMove(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
@ -141,7 +141,7 @@ class AccessibleCaretEventHub::DragCaretState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(DragCaretState)
virtual const char* Name() const override { return "DragCaretState"; }
virtual nsEventStatus OnMove(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
@ -167,7 +167,7 @@ class AccessibleCaretEventHub::PressNoCaretState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(PressNoCaretState)
virtual const char* Name() const override { return "PressNoCaretState"; }
virtual nsEventStatus OnMove(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
@ -239,7 +239,7 @@ class AccessibleCaretEventHub::ScrollState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(ScrollState)
virtual const char* Name() const override { return "ScrollState"; }
virtual void OnScrollEnd(AccessibleCaretEventHub* aContext) override
{
@ -264,7 +264,7 @@ class AccessibleCaretEventHub::PostScrollState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(PostScrollState)
virtual const char* Name() const override { return "PostScrollState"; }
virtual nsEventStatus OnPress(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint,
@ -321,7 +321,7 @@ class AccessibleCaretEventHub::LongTapState
: public AccessibleCaretEventHub::State
{
public:
NS_IMPL_STATE_UTILITIES(LongTapState)
virtual const char* Name() const override { return "LongTapState"; }
virtual nsEventStatus OnLongTap(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override

View File

@ -94,7 +94,8 @@ protected:
#define MOZ_IMPL_STATE_CLASS_GETTER(aClassName) \
AccessibleCaretEventHub::State* AccessibleCaretEventHub::aClassName() \
{ \
return AccessibleCaretEventHub::aClassName::Singleton(); \
static class aClassName singleton; \
return &singleton; \
}
// Concrete state getters
@ -169,14 +170,6 @@ protected:
class AccessibleCaretEventHub::State
{
public:
#define NS_IMPL_STATE_UTILITIES(aClassName) \
virtual const char* Name() const override { return #aClassName; } \
static aClassName* Singleton() \
{ \
static aClassName singleton; \
return &singleton; \
}
virtual const char* Name() const { return ""; }
virtual nsEventStatus OnPress(AccessibleCaretEventHub* aContext,