#ifndef SpinButtonElement_h
#define SpinButtonElement_h
#include "core/html/HTMLDivElement.h"
#include "core/page/PopupOpeningObserver.h"
#include "platform/Timer.h"
namespace WebCore {
class SpinButtonElement FINAL : public HTMLDivElement, public PopupOpeningObserver {
public:
enum UpDownState {
Indeterminate,
Down,
Up,
};
class SpinButtonOwner {
public:
virtual ~SpinButtonOwner() { }
virtual void focusAndSelectSpinButtonOwner() = 0;
virtual bool shouldSpinButtonRespondToMouseEvents() = 0;
virtual bool shouldSpinButtonRespondToWheelEvents() = 0;
virtual void spinButtonStepDown() = 0;
virtual void spinButtonStepUp() = 0;
};
static PassRefPtr<SpinButtonElement> create(Document&, SpinButtonOwner&);
UpDownState upDownState() const { return m_upDownState; }
void releaseCapture();
void removeSpinButtonOwner() { m_spinButtonOwner = 0; }
void step(int amount);
virtual bool willRespondToMouseMoveEvents() OVERRIDE;
virtual bool willRespondToMouseClickEvents() OVERRIDE;
void forwardEvent(Event*);
private:
SpinButtonElement(Document&, SpinButtonOwner&);
virtual void detach(const AttachContext& = AttachContext()) OVERRIDE;
virtual bool isSpinButtonElement() const OVERRIDE { return true; }
virtual bool isDisabledFormControl() const OVERRIDE { return shadowHost() && shadowHost()->isDisabledFormControl(); }
virtual bool matchesReadOnlyPseudoClass() const OVERRIDE;
virtual bool matchesReadWritePseudoClass() const OVERRIDE;
virtual void defaultEventHandler(Event*) OVERRIDE;
virtual void willOpenPopup() OVERRIDE;
void doStepAction(int);
void startRepeatingTimer();
void stopRepeatingTimer();
void repeatingTimerFired(Timer<SpinButtonElement>*);
virtual void setHovered(bool = true) OVERRIDE;
bool shouldRespondToMouseEvents();
virtual bool isMouseFocusable() const OVERRIDE { return false; }
SpinButtonOwner* m_spinButtonOwner;
bool m_capturing;
UpDownState m_upDownState;
UpDownState m_pressStartingState;
Timer<SpinButtonElement> m_repeatingTimer;
};
DEFINE_TYPE_CASTS(SpinButtonElement, Node, node, toElement(node)->isSpinButtonElement(), toElement(node).isSpinButtonElement());
}
#endif