[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
tkent at chromium.org
tkent at chromium.org
Wed Dec 22 11:24:26 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit dd18b61e82ee7bd4a50e4e326949bf1369893015
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Jul 22 08:20:47 2010 +0000
2010-07-22 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
Small refactoring for input value sanitization
https://bugs.webkit.org/show_bug.cgi?id=42807
Rename some functions to clarify their roles.
* dom/InputElement.cpp:
(WebCore::replaceEOLAndLimitLength):
Renamed from sanitizeUserInputValue().
(WebCore::InputElement::sanitizeValueForTextField):
Renamed from sanitizeValue(), and call replaceEOLAndLimitLength()
instead of sanitizeUserInputValue().
(WebCore::InputElement::sanitizeUserInputValue):
Just call replaceEOLAndLimitLength().
(WebCore::InputElement::updateValueIfNeeded):
Use non-static sanitizeValue() for consistency.
* dom/InputElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setInputType):
Revert the change of r63876. It is not needed because of the
updateValueIfNeeded() change.
(WebCore::HTMLInputElement::sanitizeValue):
Apply the sanitizeValue() renaming.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 97db8ed..f976cf2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2010-07-22 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ Small refactoring for input value sanitization
+ https://bugs.webkit.org/show_bug.cgi?id=42807
+
+ Rename some functions to clarify their roles.
+
+ * dom/InputElement.cpp:
+ (WebCore::replaceEOLAndLimitLength):
+ Renamed from sanitizeUserInputValue().
+ (WebCore::InputElement::sanitizeValueForTextField):
+ Renamed from sanitizeValue(), and call replaceEOLAndLimitLength()
+ instead of sanitizeUserInputValue().
+ (WebCore::InputElement::sanitizeUserInputValue):
+ Just call replaceEOLAndLimitLength().
+ (WebCore::InputElement::updateValueIfNeeded):
+ Use non-static sanitizeValue() for consistency.
+ * dom/InputElement.h:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setInputType):
+ Revert the change of r63876. It is not needed because of the
+ updateValueIfNeeded() change.
+ (WebCore::HTMLInputElement::sanitizeValue):
+ Apply the sanitizeValue() renaming.
+
2010-07-22 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebCore/dom/InputElement.cpp b/WebCore/dom/InputElement.cpp
index 079dd56..ce98197 100644
--- a/WebCore/dom/InputElement.cpp
+++ b/WebCore/dom/InputElement.cpp
@@ -145,20 +145,7 @@ void InputElement::setValueFromRenderer(InputElementData& data, InputElement* in
notifyFormStateChanged(element);
}
-String InputElement::sanitizeValue(const InputElement* inputElement, const String& proposedValue)
-{
-#if ENABLE(WCSS)
- InputElementData data = const_cast<InputElement*>(inputElement)->data();
- if (!isConformToInputMask(data, proposedValue)) {
- if (isConformToInputMask(data, data.value()))
- return data.value();
- return String();
- }
-#endif
- return InputElement::sanitizeUserInputValue(inputElement, proposedValue, s_maximumLength);
-}
-
-String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength)
+static String replaceEOLAndLimitLength(const InputElement* inputElement, const String& proposedValue, int maxLength)
{
if (!inputElement->isTextField())
return proposedValue;
@@ -179,6 +166,24 @@ String InputElement::sanitizeUserInputValue(const InputElement* inputElement, co
return string.left(newLength);
}
+String InputElement::sanitizeValueForTextField(const InputElement* inputElement, const String& proposedValue)
+{
+#if ENABLE(WCSS)
+ InputElementData data = const_cast<InputElement*>(inputElement)->data();
+ if (!isConformToInputMask(data, proposedValue)) {
+ if (isConformToInputMask(data, data.value()))
+ return data.value();
+ return String();
+ }
+#endif
+ return replaceEOLAndLimitLength(inputElement, proposedValue, s_maximumLength);
+}
+
+String InputElement::sanitizeUserInputValue(const InputElement* inputElement, const String& proposedValue, int maxLength)
+{
+ return replaceEOLAndLimitLength(inputElement, proposedValue, maxLength);
+}
+
void InputElement::handleBeforeTextInsertedEvent(InputElementData& data, InputElement* inputElement, Element* element, Event* event)
{
ASSERT(event->isBeforeTextInsertedEvent());
@@ -245,7 +250,7 @@ void InputElement::parseMaxLengthAttribute(InputElementData& data, InputElement*
void InputElement::updateValueIfNeeded(InputElementData& data, InputElement* inputElement)
{
String oldValue = data.value();
- String newValue = sanitizeValue(inputElement, oldValue);
+ String newValue = inputElement->sanitizeValue(oldValue);
if (newValue != oldValue)
inputElement->setValue(newValue);
}
diff --git a/WebCore/dom/InputElement.h b/WebCore/dom/InputElement.h
index 1d6c356..0f164f9 100644
--- a/WebCore/dom/InputElement.h
+++ b/WebCore/dom/InputElement.h
@@ -78,9 +78,11 @@ protected:
static void setValueFromRenderer(InputElementData&, InputElement*, Element*, const String&);
// Replaces CRs and LFs, shrinks the value for s_maximumLength.
// This should be applied to values from the HTML value attribute and the DOM value property.
- static String sanitizeValue(const InputElement*, const String&);
+ // This function should be called only by sanitizeValue() implementations.
+ static String sanitizeValueForTextField(const InputElement*, const String&);
// Replaces CRs and LFs, shrinks the value for the specified maximum length.
// This should be applied to values specified by users.
+ // The input string may be a fragment of the whole value.
static String sanitizeUserInputValue(const InputElement*, const String&, int);
static void handleBeforeTextInsertedEvent(InputElementData&, InputElement*, Element*, Event*);
static void parseSizeAttribute(InputElementData&, Element*, Attribute*);
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index c9fd560..3df3544 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -863,12 +863,8 @@ void HTMLInputElement::setInputType(const String& t)
}
if (!didStoreValue && willStoreValue)
m_data.setValue(sanitizeValue(getAttribute(valueAttr)));
- else {
- String oldValue = m_data.value();
- String newValue = sanitizeValue(oldValue);
- if (newValue != oldValue)
- setValue(newValue);
- }
+ else
+ InputElement::updateValueIfNeeded(m_data, this);
if (wasPasswordField && !isPasswordField)
unregisterForActivationCallbackIfNeeded();
@@ -2566,7 +2562,7 @@ FileList* HTMLInputElement::files()
String HTMLInputElement::sanitizeValue(const String& proposedValue) const
{
if (isTextField())
- return InputElement::sanitizeValue(this, proposedValue);
+ return InputElement::sanitizeValueForTextField(this, proposedValue);
// If the proposedValue is null than this is a reset scenario and we
// want the range input's value attribute to take priority over the
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list