Changeset 63879 in webkit
- Timestamp:
- Jul 22, 2010 1:20:47 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r63878 r63879 1 2010-07-22 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Small refactoring for input value sanitization 6 https://bugs.webkit.org/show_bug.cgi?id=42807 7 8 Rename some functions to clarify their roles. 9 10 * dom/InputElement.cpp: 11 (WebCore::replaceEOLAndLimitLength): 12 Renamed from sanitizeUserInputValue(). 13 (WebCore::InputElement::sanitizeValueForTextField): 14 Renamed from sanitizeValue(), and call replaceEOLAndLimitLength() 15 instead of sanitizeUserInputValue(). 16 (WebCore::InputElement::sanitizeUserInputValue): 17 Just call replaceEOLAndLimitLength(). 18 (WebCore::InputElement::updateValueIfNeeded): 19 Use non-static sanitizeValue() for consistency. 20 * dom/InputElement.h: 21 * html/HTMLInputElement.cpp: 22 (WebCore::HTMLInputElement::setInputType): 23 Revert the change of r63876. It is not needed because of the 24 updateValueIfNeeded() change. 25 (WebCore::HTMLInputElement::sanitizeValue): 26 Apply the sanitizeValue() renaming. 27 1 28 2010-07-22 Tony Gentilcore <tonyg@chromium.org> 2 29 -
trunk/WebCore/dom/InputElement.cpp
r59773 r63879 146 146 } 147 147 148 String InputElement::sanitizeValue(const InputElement* inputElement, const String& proposedValue) 149 { 150 #if ENABLE(WCSS) 151 InputElementData data = const_cast<InputElement*>(inputElement)->data(); 152 if (!isConformToInputMask(data, proposedValue)) { 153 if (isConformToInputMask(data, data.value())) 154 return data.value(); 155 return String(); 156 } 157 #endif 158 return InputElement::sanitizeUserInputValue(inputElement, proposedValue, s_maximumLength); 159 } 160 161 String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength) 148 static String replaceEOLAndLimitLength(const InputElement* inputElement, const String& proposedValue, int maxLength) 162 149 { 163 150 if (!inputElement->isTextField()) … … 178 165 } 179 166 return string.left(newLength); 167 } 168 169 String InputElement::sanitizeValueForTextField(const InputElement* inputElement, const String& proposedValue) 170 { 171 #if ENABLE(WCSS) 172 InputElementData data = const_cast<InputElement*>(inputElement)->data(); 173 if (!isConformToInputMask(data, proposedValue)) { 174 if (isConformToInputMask(data, data.value())) 175 return data.value(); 176 return String(); 177 } 178 #endif 179 return replaceEOLAndLimitLength(inputElement, proposedValue, s_maximumLength); 180 } 181 182 String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength) 183 { 184 return replaceEOLAndLimitLength(inputElement, proposedValue, maxLength); 180 185 } 181 186 … … 246 251 { 247 252 String oldValue = data.value(); 248 String newValue = sanitizeValue(inputElement,oldValue);253 String newValue = inputElement->sanitizeValue(oldValue); 249 254 if (newValue != oldValue) 250 255 inputElement->setValue(newValue); -
trunk/WebCore/dom/InputElement.h
r61752 r63879 79 79 // Replaces CRs and LFs, shrinks the value for s_maximumLength. 80 80 // This should be applied to values from the HTML value attribute and the DOM value property. 81 static String sanitizeValue(const InputElement*, const String&); 81 // This function should be called only by sanitizeValue() implementations. 82 static String sanitizeValueForTextField(const InputElement*, const String&); 82 83 // Replaces CRs and LFs, shrinks the value for the specified maximum length. 83 84 // This should be applied to values specified by users. 85 // The input string may be a fragment of the whole value. 84 86 static String sanitizeUserInputValue(const InputElement*, const String&, int); 85 87 static void handleBeforeTextInsertedEvent(InputElementData&, InputElement*, Element*, Event*); -
trunk/WebCore/html/HTMLInputElement.cpp
r63876 r63879 864 864 if (!didStoreValue && willStoreValue) 865 865 m_data.setValue(sanitizeValue(getAttribute(valueAttr))); 866 else { 867 String oldValue = m_data.value(); 868 String newValue = sanitizeValue(oldValue); 869 if (newValue != oldValue) 870 setValue(newValue); 871 } 866 else 867 InputElement::updateValueIfNeeded(m_data, this); 872 868 873 869 if (wasPasswordField && !isPasswordField) … … 2567 2563 { 2568 2564 if (isTextField()) 2569 return InputElement::sanitizeValue (this, proposedValue);2565 return InputElement::sanitizeValueForTextField(this, proposedValue); 2570 2566 2571 2567 // If the proposedValue is null than this is a reset scenario and we
Note: See TracChangeset
for help on using the changeset viewer.