|
1 /* |
|
2 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. |
|
3 * Copyright (C) 2010 Google Inc. All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions |
|
7 * are met: |
|
8 * 1. Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * 2. Redistributions in binary form must reproduce the above copyright |
|
11 * notice, this list of conditions and the following disclaimer in the |
|
12 * documentation and/or other materials provided with the distribution. |
|
13 * |
|
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
|
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
|
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
25 */ |
|
26 |
|
27 #ifndef TextControlInnerElements_h |
|
28 #define TextControlInnerElements_h |
|
29 |
|
30 #include "HTMLDivElement.h" |
|
31 #include "SpeechInputListener.h" |
|
32 |
|
33 namespace WebCore { |
|
34 |
|
35 class SpeechInput; |
|
36 class String; |
|
37 |
|
38 class TextControlInnerElement : public HTMLDivElement { |
|
39 public: |
|
40 static PassRefPtr<TextControlInnerElement> create(Node* shadowParent); |
|
41 |
|
42 void attachInnerElement(Node*, PassRefPtr<RenderStyle>, RenderArena*); |
|
43 |
|
44 protected: |
|
45 TextControlInnerElement(Document*, Node* shadowParent = 0); |
|
46 |
|
47 private: |
|
48 virtual bool isMouseFocusable() const { return false; } |
|
49 virtual bool isShadowNode() const { return m_shadowParent; } |
|
50 virtual Node* shadowParentNode() { return m_shadowParent; } |
|
51 void setShadowParentNode(Node* node) { m_shadowParent = node; } |
|
52 |
|
53 Node* m_shadowParent; |
|
54 }; |
|
55 |
|
56 class TextControlInnerTextElement : public TextControlInnerElement { |
|
57 public: |
|
58 static PassRefPtr<TextControlInnerTextElement> create(Document*, Node* shadowParent); |
|
59 |
|
60 virtual void defaultEventHandler(Event*); |
|
61 |
|
62 private: |
|
63 TextControlInnerTextElement(Document*, Node* shadowParent); |
|
64 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); |
|
65 }; |
|
66 |
|
67 class SearchFieldResultsButtonElement : public TextControlInnerElement { |
|
68 public: |
|
69 static PassRefPtr<SearchFieldResultsButtonElement> create(Document*); |
|
70 |
|
71 virtual void defaultEventHandler(Event*); |
|
72 |
|
73 private: |
|
74 SearchFieldResultsButtonElement(Document*); |
|
75 }; |
|
76 |
|
77 class SearchFieldCancelButtonElement : public TextControlInnerElement { |
|
78 public: |
|
79 static PassRefPtr<SearchFieldCancelButtonElement> create(Document*); |
|
80 |
|
81 virtual void defaultEventHandler(Event*); |
|
82 |
|
83 private: |
|
84 SearchFieldCancelButtonElement(Document*); |
|
85 |
|
86 virtual void detach(); |
|
87 |
|
88 bool m_capturing; |
|
89 }; |
|
90 |
|
91 class SpinButtonElement : public TextControlInnerElement { |
|
92 public: |
|
93 enum UpDownState { |
|
94 Indeterminate, // Hovered, but the event is not handled. |
|
95 Down, |
|
96 Up, |
|
97 }; |
|
98 |
|
99 static PassRefPtr<SpinButtonElement> create(Node*); |
|
100 UpDownState upDownState() const { return m_upDownState; } |
|
101 |
|
102 private: |
|
103 SpinButtonElement(Node*); |
|
104 |
|
105 virtual bool isSpinButtonElement() const { return true; } |
|
106 // FIXME: shadowAncestorNode() should be const. |
|
107 virtual bool isEnabledFormControl() const { return static_cast<Element*>(const_cast<SpinButtonElement*>(this)->shadowAncestorNode())->isEnabledFormControl(); } |
|
108 virtual bool isReadOnlyFormControl() const { return static_cast<Element*>(const_cast<SpinButtonElement*>(this)->shadowAncestorNode())->isReadOnlyFormControl(); } |
|
109 virtual void defaultEventHandler(Event*); |
|
110 virtual void setHovered(bool = true); |
|
111 |
|
112 bool m_capturing; |
|
113 UpDownState m_upDownState; |
|
114 }; |
|
115 |
|
116 #if ENABLE(INPUT_SPEECH) |
|
117 |
|
118 class InputFieldSpeechButtonElement |
|
119 : public TextControlInnerElement, |
|
120 public SpeechInputListener { |
|
121 public: |
|
122 static PassRefPtr<InputFieldSpeechButtonElement> create(Document*); |
|
123 |
|
124 virtual void defaultEventHandler(Event*); |
|
125 |
|
126 // SpeechInputListener methods. |
|
127 void recordingComplete(); |
|
128 void setRecognitionResult(const String& result); |
|
129 |
|
130 private: |
|
131 InputFieldSpeechButtonElement(Document*); |
|
132 virtual void detach(); |
|
133 SpeechInput* speechInput(); |
|
134 |
|
135 bool m_capturing; |
|
136 OwnPtr<SpeechInput> m_speechInput; |
|
137 }; |
|
138 |
|
139 #endif // ENABLE(INPUT_SPEECH) |
|
140 |
|
141 } // namespace |
|
142 |
|
143 #endif |