OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
6 * reserved. | 6 * reserved. |
7 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. | 7 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Common flag for HTMLInputElement::tooLong(), | 57 // Common flag for HTMLInputElement::tooLong(), |
58 // HTMLTextAreaElement::tooLong(), | 58 // HTMLTextAreaElement::tooLong(), |
59 // HTMLInputElement::tooShort() and HTMLTextAreaElement::tooShort(). | 59 // HTMLInputElement::tooShort() and HTMLTextAreaElement::tooShort(). |
60 enum NeedsToCheckDirtyFlag { CheckDirtyFlag, IgnoreDirtyFlag }; | 60 enum NeedsToCheckDirtyFlag { CheckDirtyFlag, IgnoreDirtyFlag }; |
61 | 61 |
62 ~TextControlElement() override; | 62 ~TextControlElement() override; |
63 | 63 |
64 void forwardEvent(Event*); | 64 void forwardEvent(Event*); |
65 | 65 |
66 void setFocused(bool flag) override; | 66 void setFocused(bool flag) override; |
67 InsertionNotificationRequest insertedInto(ContainerNode*) override; | |
68 | 67 |
69 // The derived class should return true if placeholder processing is needed. | 68 // The derived class should return true if placeholder processing is needed. |
70 virtual bool isPlaceholderVisible() const = 0; | 69 virtual bool isPlaceholderVisible() const = 0; |
71 virtual void setPlaceholderVisibility(bool) = 0; | 70 virtual void setPlaceholderVisibility(bool) = 0; |
72 virtual bool supportsPlaceholder() const = 0; | 71 virtual bool supportsPlaceholder() const = 0; |
73 String strippedPlaceholder() const; | 72 String strippedPlaceholder() const; |
74 HTMLElement* placeholderElement() const; | 73 HTMLElement* placeholderElement() const; |
75 void updatePlaceholderVisibility(); | 74 void updatePlaceholderVisibility(); |
76 | 75 |
77 VisiblePosition visiblePositionForIndex(int) const; | 76 VisiblePosition visiblePositionForIndex(int) const; |
(...skipping 27 matching lines...) Expand all Loading... |
105 virtual bool supportsAutocapitalize() const = 0; | 104 virtual bool supportsAutocapitalize() const = 0; |
106 virtual const AtomicString& defaultAutocapitalize() const = 0; | 105 virtual const AtomicString& defaultAutocapitalize() const = 0; |
107 const AtomicString& autocapitalize() const; | 106 const AtomicString& autocapitalize() const; |
108 void setAutocapitalize(const AtomicString&); | 107 void setAutocapitalize(const AtomicString&); |
109 | 108 |
110 int maxLength() const; | 109 int maxLength() const; |
111 int minLength() const; | 110 int minLength() const; |
112 void setMaxLength(int, ExceptionState&); | 111 void setMaxLength(int, ExceptionState&); |
113 void setMinLength(int, ExceptionState&); | 112 void setMinLength(int, ExceptionState&); |
114 | 113 |
115 // Dispatch 'input' event, and update | 114 // Dispatch 'input' event. |
116 // m_wasChangedSinceLastFormControlChangeEvent flag. | |
117 void dispatchFormControlInputEvent(); | 115 void dispatchFormControlInputEvent(); |
118 // Dispatch 'change' event if the value is updated. | 116 // Dispatch 'change' event if the value is updated. |
119 void dispatchFormControlChangeEvent(); | 117 void dispatchFormControlChangeEvent(); |
120 // Enqueue 'change' event if the value is updated. | 118 // Enqueue 'change' event if the value is updated. |
121 void enqueueChangeEvent(); | 119 void enqueueChangeEvent(); |
122 void setTextAsOfLastFormControlChangeEvent(const String& text) { | 120 // This should be called on every user-input, before the user-input changes |
123 m_textAsOfLastFormControlChangeEvent = text; | 121 // the value. |
124 } | 122 void setValueBeforeFirstUserEditIfNotSet(); |
125 // A user has changed the value since the last 'change' event. | 123 // This should be called on every user-input, after the user-input changed the |
126 bool wasChangedSinceLastFormControlChangeEvent() const { | 124 // value. The argument is the updated value. |
127 return m_wasChangedSinceLastFormControlChangeEvent; | 125 void checkIfValueWasReverted(const String&); |
128 } | 126 void clearValueBeforeFirstUserEdit(); |
129 void setChangedSinceLastFormControlChangeEvent(bool); | |
130 | 127 |
131 virtual String value() const = 0; | 128 virtual String value() const = 0; |
132 virtual void setValue( | 129 virtual void setValue( |
133 const String&, | 130 const String&, |
134 TextFieldEventBehavior = DispatchNoEvent, | 131 TextFieldEventBehavior = DispatchNoEvent, |
135 TextControlSetValueSelection = | 132 TextControlSetValueSelection = |
136 TextControlSetValueSelection::kSetSelectionToEnd) = 0; | 133 TextControlSetValueSelection::kSetSelectionToEnd) = 0; |
137 | 134 |
138 HTMLElement* innerEditorElement() const; | 135 HTMLElement* innerEditorElement() const; |
139 | 136 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 virtual bool isEmptySuggestedValue() const { return true; } | 187 virtual bool isEmptySuggestedValue() const { return true; } |
191 // Called in dispatchFocusEvent(), after placeholder process, before calling | 188 // Called in dispatchFocusEvent(), after placeholder process, before calling |
192 // parent's dispatchFocusEvent(). | 189 // parent's dispatchFocusEvent(). |
193 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) {} | 190 virtual void handleFocusEvent(Element* /* oldFocusedNode */, WebFocusType) {} |
194 // Called in dispatchBlurEvent(), after placeholder process, before calling | 191 // Called in dispatchBlurEvent(), after placeholder process, before calling |
195 // parent's dispatchBlurEvent(). | 192 // parent's dispatchBlurEvent(). |
196 virtual void handleBlurEvent() {} | 193 virtual void handleBlurEvent() {} |
197 | 194 |
198 bool placeholderShouldBeVisible() const; | 195 bool placeholderShouldBeVisible() const; |
199 | 196 |
200 String m_textAsOfLastFormControlChangeEvent; | 197 // In m_valueBeforeFirstUserEdit, we distinguish a null String and zero-length |
201 bool m_wasChangedSinceLastFormControlChangeEvent = false; | 198 // String. Null String means the field doesn't have any data yet, and |
| 199 // zero-length String is a valid data. |
| 200 String m_valueBeforeFirstUserEdit; |
202 bool m_lastChangeWasUserEdit; | 201 bool m_lastChangeWasUserEdit; |
203 | 202 |
204 unsigned m_cachedSelectionStart; | 203 unsigned m_cachedSelectionStart; |
205 unsigned m_cachedSelectionEnd; | 204 unsigned m_cachedSelectionEnd; |
206 TextFieldSelectionDirection m_cachedSelectionDirection; | 205 TextFieldSelectionDirection m_cachedSelectionDirection; |
207 | 206 |
208 FRIEND_TEST_ALL_PREFIXES(TextControlElementTest, IndexForPosition); | 207 FRIEND_TEST_ALL_PREFIXES(TextControlElementTest, IndexForPosition); |
209 }; | 208 }; |
210 | 209 |
211 inline bool isTextControlElement(const Element& element) { | 210 inline bool isTextControlElement(const Element& element) { |
212 return element.isTextControl(); | 211 return element.isTextControl(); |
213 } | 212 } |
214 | 213 |
215 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(TextControlElement); | 214 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(TextControlElement); |
216 | 215 |
217 TextControlElement* enclosingTextControl(const Position&); | 216 TextControlElement* enclosingTextControl(const Position&); |
218 TextControlElement* enclosingTextControl(const Node*); | 217 TextControlElement* enclosingTextControl(const Node*); |
219 | 218 |
220 } // namespace blink | 219 } // namespace blink |
221 | 220 |
222 #endif | 221 #endif |
OLD | NEW |