OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 26 matching lines...) Expand all Loading... |
37 public: | 37 public: |
38 enum UpDownState { | 38 enum UpDownState { |
39 Indeterminate, // Hovered, but the event is not handled. | 39 Indeterminate, // Hovered, but the event is not handled. |
40 Down, | 40 Down, |
41 Up, | 41 Up, |
42 }; | 42 }; |
43 enum EventDispatch { | 43 enum EventDispatch { |
44 EventDispatchAllowed, | 44 EventDispatchAllowed, |
45 EventDispatchDisallowed, | 45 EventDispatchDisallowed, |
46 }; | 46 }; |
47 class SpinButtonOwner { | 47 class SpinButtonOwner : public WillBeGarbageCollectedMixin { |
48 public: | 48 public: |
49 virtual ~SpinButtonOwner() { } | 49 virtual ~SpinButtonOwner() { } |
50 virtual void focusAndSelectSpinButtonOwner() = 0; | 50 virtual void focusAndSelectSpinButtonOwner() = 0; |
51 virtual bool shouldSpinButtonRespondToMouseEvents() = 0; | 51 virtual bool shouldSpinButtonRespondToMouseEvents() = 0; |
52 virtual bool shouldSpinButtonRespondToWheelEvents() = 0; | 52 virtual bool shouldSpinButtonRespondToWheelEvents() = 0; |
53 virtual void spinButtonDidReleaseMouseCapture(EventDispatch) = 0; | 53 virtual void spinButtonDidReleaseMouseCapture(EventDispatch) = 0; |
54 virtual void spinButtonStepDown() = 0; | 54 virtual void spinButtonStepDown() = 0; |
55 virtual void spinButtonStepUp() = 0; | 55 virtual void spinButtonStepUp() = 0; |
56 }; | 56 }; |
57 | 57 |
58 // The owner of SpinButtonElement must call removeSpinButtonOwner | 58 // The owner of SpinButtonElement must call removeSpinButtonOwner |
59 // because SpinButtonElement can be outlive SpinButtonOwner | 59 // because SpinButtonElement can be outlive SpinButtonOwner |
60 // implementation, e.g. during event handling. | 60 // implementation, e.g. during event handling. |
61 static PassRefPtr<SpinButtonElement> create(Document&, SpinButtonOwner&); | 61 static PassRefPtr<SpinButtonElement> create(Document&, SpinButtonOwner&); |
62 UpDownState upDownState() const { return m_upDownState; } | 62 UpDownState upDownState() const { return m_upDownState; } |
63 void releaseCapture(EventDispatch = EventDispatchAllowed); | 63 void releaseCapture(EventDispatch = EventDispatchAllowed); |
64 void removeSpinButtonOwner() { m_spinButtonOwner = 0; } | 64 void removeSpinButtonOwner() { m_spinButtonOwner = nullptr; } |
65 | 65 |
66 void step(int amount); | 66 void step(int amount); |
67 | 67 |
68 virtual bool willRespondToMouseMoveEvents() OVERRIDE; | 68 virtual bool willRespondToMouseMoveEvents() OVERRIDE; |
69 virtual bool willRespondToMouseClickEvents() OVERRIDE; | 69 virtual bool willRespondToMouseClickEvents() OVERRIDE; |
70 | 70 |
71 void forwardEvent(Event*); | 71 void forwardEvent(Event*); |
72 | 72 |
| 73 virtual void trace(Visitor*) OVERRIDE; |
| 74 |
73 private: | 75 private: |
74 SpinButtonElement(Document&, SpinButtonOwner&); | 76 SpinButtonElement(Document&, SpinButtonOwner&); |
75 | 77 |
76 virtual void detach(const AttachContext&) OVERRIDE; | 78 virtual void detach(const AttachContext&) OVERRIDE; |
77 virtual bool isSpinButtonElement() const OVERRIDE { return true; } | 79 virtual bool isSpinButtonElement() const OVERRIDE { return true; } |
78 virtual bool isDisabledFormControl() const OVERRIDE { return shadowHost() &&
shadowHost()->isDisabledFormControl(); } | 80 virtual bool isDisabledFormControl() const OVERRIDE { return shadowHost() &&
shadowHost()->isDisabledFormControl(); } |
79 virtual bool matchesReadOnlyPseudoClass() const OVERRIDE; | 81 virtual bool matchesReadOnlyPseudoClass() const OVERRIDE; |
80 virtual bool matchesReadWritePseudoClass() const OVERRIDE; | 82 virtual bool matchesReadWritePseudoClass() const OVERRIDE; |
81 virtual void defaultEventHandler(Event*) OVERRIDE; | 83 virtual void defaultEventHandler(Event*) OVERRIDE; |
82 virtual void willOpenPopup() OVERRIDE; | 84 virtual void willOpenPopup() OVERRIDE; |
83 void doStepAction(int); | 85 void doStepAction(int); |
84 void startRepeatingTimer(); | 86 void startRepeatingTimer(); |
85 void stopRepeatingTimer(); | 87 void stopRepeatingTimer(); |
86 void repeatingTimerFired(Timer<SpinButtonElement>*); | 88 void repeatingTimerFired(Timer<SpinButtonElement>*); |
87 virtual void setHovered(bool = true) OVERRIDE; | 89 virtual void setHovered(bool = true) OVERRIDE; |
88 bool shouldRespondToMouseEvents(); | 90 bool shouldRespondToMouseEvents(); |
89 virtual bool isMouseFocusable() const OVERRIDE { return false; } | 91 virtual bool isMouseFocusable() const OVERRIDE { return false; } |
90 | 92 |
91 SpinButtonOwner* m_spinButtonOwner; | 93 RawPtrWillBeMember<SpinButtonOwner> m_spinButtonOwner; |
92 bool m_capturing; | 94 bool m_capturing; |
93 UpDownState m_upDownState; | 95 UpDownState m_upDownState; |
94 UpDownState m_pressStartingState; | 96 UpDownState m_pressStartingState; |
95 Timer<SpinButtonElement> m_repeatingTimer; | 97 Timer<SpinButtonElement> m_repeatingTimer; |
96 }; | 98 }; |
97 | 99 |
98 DEFINE_TYPE_CASTS(SpinButtonElement, Node, node, toElement(node)->isSpinButtonEl
ement(), toElement(node).isSpinButtonElement()); | 100 DEFINE_TYPE_CASTS(SpinButtonElement, Node, node, toElement(node)->isSpinButtonEl
ement(), toElement(node).isSpinButtonElement()); |
99 | 101 |
100 } // namespace | 102 } // namespace |
101 | 103 |
102 #endif | 104 #endif |
OLD | NEW |