Title: [116756] trunk/Source/WebCore
Revision
116756
Author
commit-qu...@webkit.org
Date
2012-05-11 05:56:04 -0700 (Fri, 11 May 2012)

Log Message

Unreviewed, rolling out r116752.
http://trac.webkit.org/changeset/116752
https://bugs.webkit.org/show_bug.cgi?id=86201

Build failure on Chromium-mac (Requested by tkent on #webkit).

Patch by Sheriff Bot <webkit.review....@gmail.com> on 2012-05-11

* html/FormAssociatedElement.cpp:
* html/FormAssociatedElement.h:
(FormAssociatedElement):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::setCustomValidity):
* html/HTMLFormControlElement.h:
(HTMLFormControlElement):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isValidValue):
(WebCore::HTMLInputElement::typeMismatch):
(WebCore::HTMLInputElement::valueMissing):
(WebCore::HTMLInputElement::patternMismatch):
(WebCore::HTMLInputElement::rangeUnderflow):
(WebCore::HTMLInputElement::rangeOverflow):
(WebCore::HTMLInputElement::minimum):
(WebCore::HTMLInputElement::maximum):
(WebCore::HTMLInputElement::stepMismatch):
(WebCore::HTMLInputElement::minimumString):
(WebCore::HTMLInputElement::maximumString):
(WebCore):
(WebCore::HTMLInputElement::stepBaseString):
(WebCore::HTMLInputElement::stepString):
(WebCore::HTMLInputElement::typeMismatchText):
(WebCore::HTMLInputElement::valueMissingText):
(WebCore::HTMLInputElement::isInRange):
(WebCore::HTMLInputElement::isOutOfRange):
* html/HTMLInputElement.h:
(HTMLInputElement):
* html/HTMLObjectElement.h:
(WebCore::HTMLObjectElement::setCustomValidity):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::valueMissing):
* html/HTMLSelectElement.h:
(HTMLSelectElement):
* html/HTMLTextAreaElement.cpp:
* html/HTMLTextAreaElement.h:
(WebCore::HTMLTextAreaElement::valueMissing):
(HTMLTextAreaElement):
* html/InputType.cpp:
(WebCore::InputType::alignValueForStep):
(WebCore::InputType::stepUpFromRenderer):
* html/InputType.h:
(InputType):
* html/ValidityState.cpp:
(WebCore::ValidityState::validationMessage):
(WebCore):
(WebCore::ValidityState::setCustomErrorMessage):
(WebCore::ValidityState::valueMissing):
(WebCore::ValidityState::typeMismatch):
(WebCore::ValidityState::patternMismatch):
(WebCore::ValidityState::tooLong):
(WebCore::ValidityState::rangeUnderflow):
(WebCore::ValidityState::rangeOverflow):
(WebCore::ValidityState::stepMismatch):
(WebCore::ValidityState::customError):
(WebCore::ValidityState::valid):
* html/ValidityState.h:
(ValidityState):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116755 => 116756)


--- trunk/Source/WebCore/ChangeLog	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/ChangeLog	2012-05-11 12:56:04 UTC (rev 116756)
@@ -1,3 +1,70 @@
+2012-05-11  Sheriff Bot  <webkit.review....@gmail.com>
+
+        Unreviewed, rolling out r116752.
+        http://trac.webkit.org/changeset/116752
+        https://bugs.webkit.org/show_bug.cgi?id=86201
+
+        Build failure on Chromium-mac (Requested by tkent on #webkit).
+
+        * html/FormAssociatedElement.cpp:
+        * html/FormAssociatedElement.h:
+        (FormAssociatedElement):
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::setCustomValidity):
+        * html/HTMLFormControlElement.h:
+        (HTMLFormControlElement):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::isValidValue):
+        (WebCore::HTMLInputElement::typeMismatch):
+        (WebCore::HTMLInputElement::valueMissing):
+        (WebCore::HTMLInputElement::patternMismatch):
+        (WebCore::HTMLInputElement::rangeUnderflow):
+        (WebCore::HTMLInputElement::rangeOverflow):
+        (WebCore::HTMLInputElement::minimum):
+        (WebCore::HTMLInputElement::maximum):
+        (WebCore::HTMLInputElement::stepMismatch):
+        (WebCore::HTMLInputElement::minimumString):
+        (WebCore::HTMLInputElement::maximumString):
+        (WebCore):
+        (WebCore::HTMLInputElement::stepBaseString):
+        (WebCore::HTMLInputElement::stepString):
+        (WebCore::HTMLInputElement::typeMismatchText):
+        (WebCore::HTMLInputElement::valueMissingText):
+        (WebCore::HTMLInputElement::isInRange):
+        (WebCore::HTMLInputElement::isOutOfRange):
+        * html/HTMLInputElement.h:
+        (HTMLInputElement):
+        * html/HTMLObjectElement.h:
+        (WebCore::HTMLObjectElement::setCustomValidity):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::valueMissing):
+        * html/HTMLSelectElement.h:
+        (HTMLSelectElement):
+        * html/HTMLTextAreaElement.cpp:
+        * html/HTMLTextAreaElement.h:
+        (WebCore::HTMLTextAreaElement::valueMissing):
+        (HTMLTextAreaElement):
+        * html/InputType.cpp:
+        (WebCore::InputType::alignValueForStep):
+        (WebCore::InputType::stepUpFromRenderer):
+        * html/InputType.h:
+        (InputType):
+        * html/ValidityState.cpp:
+        (WebCore::ValidityState::validationMessage):
+        (WebCore):
+        (WebCore::ValidityState::setCustomErrorMessage):
+        (WebCore::ValidityState::valueMissing):
+        (WebCore::ValidityState::typeMismatch):
+        (WebCore::ValidityState::patternMismatch):
+        (WebCore::ValidityState::tooLong):
+        (WebCore::ValidityState::rangeUnderflow):
+        (WebCore::ValidityState::rangeOverflow):
+        (WebCore::ValidityState::stepMismatch):
+        (WebCore::ValidityState::customError):
+        (WebCore::ValidityState::valid):
+        * html/ValidityState.h:
+        (ValidityState):
+
 2012-05-11  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: Search box doesn't allow CSS selectors anymore

Modified: trunk/Source/WebCore/html/FormAssociatedElement.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/FormAssociatedElement.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/FormAssociatedElement.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -157,69 +157,6 @@
         resetFormOwner();
 }
 
-bool FormAssociatedElement::customError() const
-{
-    const HTMLElement* element = toHTMLElement(this);
-    return element->willValidate() && !m_customValidationMessage.isEmpty();
-}
-
-bool FormAssociatedElement::patternMismatch() const
-{
-    return false;
-}
-
-bool FormAssociatedElement::rangeOverflow() const
-{
-    return false;
-}
-
-bool FormAssociatedElement::rangeUnderflow() const
-{
-    return false;
-}
-
-bool FormAssociatedElement::stepMismatch() const
-{
-    return false;
-}
-
-bool FormAssociatedElement::tooLong() const
-{
-    return false;
-}
-
-bool FormAssociatedElement::typeMismatch() const
-{
-    return false;
-}
-
-bool FormAssociatedElement::valid() const
-{
-    bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow()
-        || tooLong() || patternMismatch() || valueMissing() || customError();
-    return !someError;
-}
-
-bool FormAssociatedElement::valueMissing() const
-{
-    return false;
-}
-
-String FormAssociatedElement::customValidationMessage() const
-{
-    return m_customValidationMessage;
-}
-
-String FormAssociatedElement::validationMessage() const
-{
-    return customError() ? m_customValidationMessage : String();
-}
-
-void FormAssociatedElement::setCustomValidity(const String& error)
-{
-    m_customValidationMessage = error;
-}
-
 const HTMLElement* toHTMLElement(const FormAssociatedElement* associatedElement)
 {
     if (associatedElement->isFormControlElement())

Modified: trunk/Source/WebCore/html/FormAssociatedElement.h (116755 => 116756)


--- trunk/Source/WebCore/html/FormAssociatedElement.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/FormAssociatedElement.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -60,22 +60,6 @@
 
     void formRemovedFromTree(const Node* formRoot);
 
-    // ValidityState attribute implementations
-    bool customError() const;
-
-    // Override functions for patterMismatch, rangeOverflow, rangerUnderflow,
-    // stepMismatch, tooLong and valueMissing must call willValidate method.
-    virtual bool patternMismatch() const;
-    virtual bool rangeOverflow() const;
-    virtual bool rangeUnderflow() const;
-    virtual bool stepMismatch() const;
-    virtual bool tooLong() const;
-    virtual bool typeMismatch() const;
-    virtual bool valueMissing() const;
-    virtual String validationMessage() const;
-    bool valid() const;
-    virtual void setCustomValidity(const String&);
-
 protected:
     FormAssociatedElement();
 
@@ -92,8 +76,6 @@
     virtual void willChangeForm();
     virtual void didChangeForm();
 
-    String customValidationMessage() const;
-
 private:
     virtual const AtomicString& formControlName() const = 0;
 
@@ -102,7 +84,6 @@
 
     HTMLFormElement* m_form;
     OwnPtr<ValidityState> m_validityState;
-    String m_customValidationMessage;
 };
 
 HTMLElement* toHTMLElement(FormAssociatedElement*);

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -484,8 +484,7 @@
 
 void HTMLFormControlElement::setCustomValidity(const String& error)
 {
-    FormAssociatedElement::setCustomValidity(error);
-    setNeedsValidityCheck();
+    validity()->setCustomErrorMessage(error);
 }
 
 void HTMLFormControlElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode)

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLFormControlElement.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -101,7 +101,7 @@
     bool checkValidity(Vector<RefPtr<FormAssociatedElement> >* unhandledInvalidControls = 0);
     // This must be called when a validation constraint or control value is changed.
     void setNeedsValidityCheck();
-    virtual void setCustomValidity(const String&) OVERRIDE;
+    void setCustomValidity(const String&);
 
     bool readOnly() const { return m_readOnly; }
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -191,32 +191,27 @@
         return false;
     }
     return !m_inputType->typeMismatchFor(value)
-        && !m_inputType->stepMismatch(value)
-        && !m_inputType->rangeUnderflow(value)
-        && !m_inputType->rangeOverflow(value)
+        && !stepMismatch(value)
+        && !rangeUnderflow(value)
+        && !rangeOverflow(value)
         && !tooLong(value, IgnoreDirtyFlag)
-        && !m_inputType->patternMismatch(value)
-        && !m_inputType->valueMissing(value);
+        && !patternMismatch(value)
+        && !valueMissing(value);
 }
 
-bool HTMLInputElement::tooLong() const
-{
-    return willValidate() && tooLong(value(), CheckDirtyFlag);
-}
-
 bool HTMLInputElement::typeMismatch() const
 {
-    return willValidate() && m_inputType->typeMismatch();
+    return m_inputType->typeMismatch();
 }
 
-bool HTMLInputElement::valueMissing() const
+bool HTMLInputElement::valueMissing(const String& value) const
 {
-    return willValidate() && m_inputType->valueMissing(value());
+    return m_inputType->valueMissing(value);
 }
 
-bool HTMLInputElement::patternMismatch() const
+bool HTMLInputElement::patternMismatch(const String& value) const
 {
-    return willValidate() && m_inputType->patternMismatch(value());
+    return m_inputType->patternMismatch(value);
 }
 
 bool HTMLInputElement::tooLong(const String& value, NeedsToCheckDirtyFlag check) const
@@ -237,42 +232,70 @@
     return numGraphemeClusters(value) > static_cast<unsigned>(max);
 }
 
-bool HTMLInputElement::rangeUnderflow() const
+bool HTMLInputElement::rangeUnderflow(const String& value) const
 {
-    return willValidate() && m_inputType->rangeUnderflow(value());
+    return m_inputType->rangeUnderflow(value);
 }
 
-bool HTMLInputElement::rangeOverflow() const
+bool HTMLInputElement::rangeOverflow(const String& value) const
 {
-    return willValidate() && m_inputType->rangeOverflow(value());
+    return m_inputType->rangeOverflow(value);
 }
 
-String HTMLInputElement::validationMessage() const
+double HTMLInputElement::minimum() const
 {
-    if (!willValidate())
-        return String();
+    return m_inputType->minimum();
+}
 
-    if (customError())
-        return customValidationMessage();
+double HTMLInputElement::maximum() const
+{
+    return m_inputType->maximum();
+}
 
-    return m_inputType->validationMessage();
+bool HTMLInputElement::stepMismatch(const String& value) const
+{
+    double step;
+    if (!getAllowedValueStep(&step))
+        return false;
+    return m_inputType->stepMismatch(value, step);
 }
 
-double HTMLInputElement::minimum() const
+String HTMLInputElement::minimumString() const
 {
-    return m_inputType->minimum();
+    return m_inputType->serialize(minimum());
 }
 
-double HTMLInputElement::maximum() const
+String HTMLInputElement::maximumString() const
 {
-    return m_inputType->maximum();
+    return m_inputType->serialize(maximum());
 }
 
-bool HTMLInputElement::stepMismatch() const
+String HTMLInputElement::stepBaseString() const
 {
-    return willValidate() && m_inputType->stepMismatch(value());
+    return m_inputType->serialize(m_inputType->stepBase());
 }
 
+String HTMLInputElement::stepString() const
+{
+    double step;
+    if (!getAllowedValueStep(&step)) {
+        // stepString() should be called only if stepMismatch() can be true.
+        ASSERT_NOT_REACHED();
+        return String();
+    }
+    return serializeForNumberType(step / m_inputType->stepScaleFactor());
+}
+
+String HTMLInputElement::typeMismatchText() const
+{
+    return m_inputType->typeMismatchText();
+}
+
+String HTMLInputElement::valueMissingText() const
+{
+    return m_inputType->valueMissingText();
+}
+
 bool HTMLInputElement::getAllowedValueStep(double* step) const
 {
     return m_inputType->getAllowedValueStep(step);
@@ -1252,12 +1275,12 @@
 
 bool HTMLInputElement::isInRange() const
 {
-    return m_inputType->supportsRangeLimitation() && !m_inputType->rangeUnderflow(value()) && !m_inputType->rangeOverflow(value());
+    return m_inputType->supportsRangeLimitation() && !rangeUnderflow(value()) && !rangeOverflow(value());
 }
 
 bool HTMLInputElement::isOutOfRange() const
 {
-    return m_inputType->supportsRangeLimitation() && (m_inputType->rangeUnderflow(value()) || m_inputType->rangeOverflow(value()));
+    return m_inputType->supportsRangeLimitation() && (rangeUnderflow(value()) || rangeOverflow(value()));
 }
 
 bool HTMLInputElement::needsSuspensionCallback()

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -48,15 +48,13 @@
     virtual bool shouldAutocomplete() const;
 
     // For ValidityState
-    virtual bool patternMismatch() const OVERRIDE;
-    virtual bool rangeUnderflow() const OVERRIDE;
-    virtual bool rangeOverflow() const;
-    virtual bool stepMismatch() const OVERRIDE;
-    virtual bool tooLong() const OVERRIDE;
-    virtual bool typeMismatch() const OVERRIDE;
-    virtual bool valueMissing() const OVERRIDE;
-    virtual String validationMessage() const OVERRIDE;
-
+    bool typeMismatch() const;
+    // valueMissing() ignores the specified string value for CHECKBOX and RADIO.
+    bool valueMissing(const String&) const;
+    bool patternMismatch(const String&) const;
+    bool tooLong(const String&, NeedsToCheckDirtyFlag) const;
+    bool rangeUnderflow(const String&) const;
+    bool rangeOverflow(const String&) const;
     // Returns the minimum value for type=date, number, or range.  Don't call this for other types.
     double minimum() const;
     // Returns the maximum value for type=date, number, or range.  Don't call this for other types.
@@ -66,6 +64,15 @@
     // Returns false if there is no "allowed value step."
     bool getAllowedValueStep(double*) const;
 
+    // For ValidityState.
+    bool stepMismatch(const String&) const;
+    String minimumString() const;
+    String maximumString() const;
+    String stepBaseString() const;
+    String stepString() const;
+    String typeMismatchText() const;
+    String valueMissingText() const;
+
     // Implementations of HTMLInputElement::stepUp() and stepDown().
     void stepUp(int, ExceptionCode&);
     void stepDown(int, ExceptionCode&);
@@ -318,7 +325,6 @@
 
     bool supportsMaxLength() const { return isTextType(); }
     bool isTextType() const;
-    bool tooLong(const String&, NeedsToCheckDirtyFlag) const;
 
     virtual bool supportsPlaceholder() const;
     virtual bool isPlaceholderEmpty() const OVERRIDE;

Modified: trunk/Source/WebCore/html/HTMLObjectElement.h (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLObjectElement.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLObjectElement.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -56,7 +56,7 @@
     // Note that the object elements are always barred from constraint validation.
     String validationMessage() { return String(); }
     bool checkValidity() { return true; }
-    virtual void setCustomValidity(const String&) OVERRIDE { }
+    void setCustomValidity(const String&) { }
 
     using TreeShared<ContainerNode>::ref;
     using TreeShared<ContainerNode>::deref;

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -41,7 +41,6 @@
 #include "HTMLOptionElement.h"
 #include "HTMLOptionsCollection.h"
 #include "KeyboardEvent.h"
-#include "LocalizedStrings.h"
 #include "MouseEvent.h"
 #include "NodeRenderingContext.h"
 #include "Page.h"
@@ -146,22 +145,8 @@
     return !listIndex && option->value().isEmpty();
 }
 
-String HTMLSelectElement::validationMessage() const
-{
-    if (!willValidate())
-        return String();
-
-    if (customError())
-        return customValidationMessage();
-
-    return valueMissing() ? validationMessageValueMissingForSelectText() : String();
-}
-
 bool HTMLSelectElement::valueMissing() const
 {
-    if (!willValidate())
-        return false;
-
     if (!isRequiredFormControl())
         return false;
 

Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLSelectElement.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -46,8 +46,7 @@
     void optionSelectedByUser(int index, bool dispatchChangeEvent, bool allowMultipleSelection = false);
 
     // For ValidityState
-    virtual String validationMessage() const OVERRIDE;
-    virtual bool valueMissing() const OVERRIDE;
+    bool valueMissing() const;
 
     unsigned length() const;
 

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -37,7 +37,6 @@
 #include "FormDataList.h"
 #include "Frame.h"
 #include "HTMLNames.h"
-#include "LocalizedStrings.h"
 #include "RenderTextControlMultiLine.h"
 #include "ShadowRoot.h"
 #include "Text.h"
@@ -424,33 +423,6 @@
         setAttribute(maxlengthAttr, String::number(newValue));
 }
 
-String HTMLTextAreaElement::validationMessage() const
-{
-    if (!willValidate())
-        return String();
-
-    if (customError())
-        return customValidationMessage();
-
-    if (valueMissing())
-        return validationMessageValueMissingText();
-
-    if (tooLong())
-        return validationMessageTooLongText(numGraphemeClusters(value()), maxLength());
-
-    return String();
-}
-
-bool HTMLTextAreaElement::valueMissing() const
-{
-    return willValidate() && valueMissing(value());
-}
-
-bool HTMLTextAreaElement::tooLong() const
-{
-    return willValidate() && tooLong(value(), CheckDirtyFlag);
-}
-
 bool HTMLTextAreaElement::tooLong(const String& value, NeedsToCheckDirtyFlag check) const
 {
     // Return false for the default value or value set by script even if it is

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (116755 => 116756)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -47,10 +47,8 @@
     int textLength() const { return value().length(); }
     virtual int maxLength() const;
     void setMaxLength(int, ExceptionCode&);
-    // For ValidityState
-    virtual String validationMessage() const OVERRIDE;
-    virtual bool valueMissing() const OVERRIDE;
-    virtual bool tooLong() const OVERRIDE;
+    bool valueMissing(const String& value) const { return isRequiredFormControl() && !disabled() && !readOnly() && value.isEmpty(); }
+    bool tooLong(const String&, NeedsToCheckDirtyFlag) const;
     bool isValidValue(const String&) const;
     
     virtual HTMLElement* innerTextElement() const;
@@ -110,9 +108,6 @@
 
     virtual bool shouldUseInputMethod();
 
-    bool valueMissing(const String& value) const { return isRequiredFormControl() && !disabled() && !readOnly() && value.isEmpty(); }
-    bool tooLong(const String&, NeedsToCheckDirtyFlag) const;
-
     int m_rows;
     int m_cols;
     WrapMethod m_wrap;

Modified: trunk/Source/WebCore/html/InputType.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/InputType.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -283,14 +283,6 @@
     return false;
 }
 
-bool InputType::stepMismatch(const String& value) const
-{
-    double step;
-    if (!getAllowedValueStep(&step))
-        return false;
-    return stepMismatch(value, step);
-}
-
 bool InputType::stepMismatch(const String&, double) const
 {
     // Non-supported types should be rejected by HTMLInputElement::getAllowedValueStep().
@@ -346,41 +338,6 @@
     return validationMessageValueMissingText();
 }
 
-String InputType::validationMessage() const
-{
-    const String value = element()->value();
-
-    // The order of the following checks is meaningful. e.g. We'd like to show the
-    // valueMissing message even if the control has other validation errors.
-    if (valueMissing(value))
-        return valueMissingText();
-
-    if (typeMismatch())
-        return typeMismatchText();
-
-    if (patternMismatch(value))
-        return validationMessagePatternMismatchText();
-
-    if (element()->tooLong())
-        return validationMessageTooLongText(numGraphemeClusters(value), element()->maxLength());
-
-    if (rangeUnderflow(value))
-        return validationMessageRangeUnderflowText(serialize(minimum()));
-
-    if (rangeOverflow(value))
-        return validationMessageRangeOverflowText(serialize(maximum()));
-
-    if (stepMismatch(value)) {
-        String stepString;
-        double step;
-        if (getAllowedValueStep(&step))
-            stepString = serializeForNumberType(step / stepScaleFactor());
-        return validationMessageStepMismatchText(serialize(stepBase()), stepString);
-    }
-
-    return String();
-}
-
 void InputType::handleClickEvent(MouseEvent*)
 {
 }
@@ -913,7 +870,7 @@
     unsigned baseDecimalPlaces;
     double base = stepBaseWithDecimalPlaces(&baseDecimalPlaces);
     baseDecimalPlaces = min(baseDecimalPlaces, 16u);
-    if (stepMismatch(element()->value())) {
+    if (element()->stepMismatch(element()->value())) {
         double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, currentDecimalPlaces)));
         newValue = round(newValue * scale) / scale;
     } else {
@@ -1066,7 +1023,7 @@
         element()->setValue(serialize(sign > 0 ? minimum() : maximum()), DispatchInputAndChangeEvent);
     else {
         ExceptionCode ec;
-        if (stepMismatch(element()->value())) {
+        if (element()->stepMismatch(element()->value())) {
             ASSERT(step);
             double newValue;
             double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, baseDecimalPlaces)));

Modified: trunk/Source/WebCore/html/InputType.h (116755 => 116756)


--- trunk/Source/WebCore/html/InputType.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/InputType.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -140,7 +140,7 @@
     virtual void setValueAsNumber(double, TextFieldEventBehavior, ExceptionCode&) const;
 
     // Validation functions
-    virtual String validationMessage() const;
+
     virtual bool supportsValidation() const;
     virtual bool typeMismatchFor(const String&) const;
     // Type check for the current input value. We do nothing for some types
@@ -157,7 +157,6 @@
     virtual double minimum() const;
     virtual double maximum() const;
     virtual bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const;
-    bool stepMismatch(const String&) const;
     virtual bool stepMismatch(const String&, double step) const;
     virtual double stepBase() const;
     virtual double stepBaseWithDecimalPlaces(unsigned*) const;

Modified: trunk/Source/WebCore/html/ValidityState.cpp (116755 => 116756)


--- trunk/Source/WebCore/html/ValidityState.cpp	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/ValidityState.cpp	2012-05-11 12:56:04 UTC (rev 116756)
@@ -38,52 +38,177 @@
 
 String ValidityState::validationMessage() const
 {
-    return m_control->validationMessage();
+    if (!toHTMLElement(m_control)->willValidate())
+        return String();
+
+    if (customError())
+        return m_customErrorMessage;
+    HTMLElement* element = toHTMLElement(m_control);
+    bool isInputElement = element->isFormControlElement() && element->hasTagName(inputTag);
+    bool isTextAreaElement = element->isFormControlElement() && element->hasTagName(textareaTag);
+    // The order of the following checks is meaningful. e.g. We'd like to show the
+    // valueMissing message even if the control has other validation errors.
+    if (valueMissing()) {
+        if (element->hasTagName(selectTag))
+            return validationMessageValueMissingForSelectText();
+        if (isInputElement)
+            return static_cast<HTMLInputElement*>(element)->valueMissingText();
+        return validationMessageValueMissingText();
+    }
+    if (typeMismatch()) {
+        if (isInputElement)
+            return static_cast<HTMLInputElement*>(element)->typeMismatchText();
+        return validationMessageTypeMismatchText();
+    }
+    if (patternMismatch())
+        return validationMessagePatternMismatchText();
+    if (tooLong()) {
+        if (!isInputElement && !isTextAreaElement) {
+            ASSERT_NOT_REACHED();
+            return String();
+        }
+        HTMLTextFormControlElement* text = static_cast<HTMLTextFormControlElement*>(element);
+        return validationMessageTooLongText(numGraphemeClusters(text->value()), text->maxLength());
+    }
+    if (rangeUnderflow()) {
+        if (!isInputElement) {
+            ASSERT_NOT_REACHED();
+            return String();
+        }
+        return validationMessageRangeUnderflowText(static_cast<HTMLInputElement*>(element)->minimumString());
+    }
+    if (rangeOverflow()) {
+        if (!isInputElement) {
+            ASSERT_NOT_REACHED();
+            return String();
+        }
+        return validationMessageRangeOverflowText(static_cast<HTMLInputElement*>(element)->maximumString());
+    }
+    if (stepMismatch()) {
+        if (!isInputElement) {
+            ASSERT_NOT_REACHED();
+            return String();
+        }
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+        return validationMessageStepMismatchText(input->stepBaseString(), input->stepString());
+    }
+
+    return String();
 }
 
+void ValidityState::setCustomErrorMessage(const String& message)
+{
+    m_customErrorMessage = message;
+    if (m_control->isFormControlElement())
+        static_cast<HTMLFormControlElement*>(m_control)->setNeedsValidityCheck();
+}
+
 bool ValidityState::valueMissing() const
 {
-    return m_control->valueMissing();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (element->hasTagName(inputTag)) {
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+        return input->valueMissing(input->value());
+    }
+    if (element->hasTagName(textareaTag)) {
+        HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(element);
+        return textArea->valueMissing(textArea->value());
+    }
+    if (element->hasTagName(selectTag))
+        return toHTMLSelectElement(element)->valueMissing();
+    return false;
 }
 
 bool ValidityState::typeMismatch() const
 {
-    return m_control->typeMismatch();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (!element->hasTagName(inputTag))
+        return false;
+    return static_cast<HTMLInputElement*>(element)->typeMismatch();
 }
 
 bool ValidityState::patternMismatch() const
 {
-    return m_control->patternMismatch();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (!element->hasTagName(inputTag))
+        return false;
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+    return input->patternMismatch(input->value());
 }
 
 bool ValidityState::tooLong() const
 {
-    return m_control->tooLong();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (element->hasTagName(inputTag)) {
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+        return input->tooLong(input->value(), HTMLTextFormControlElement::CheckDirtyFlag);
+    }
+    if (element->hasTagName(textareaTag)) {
+        HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(element);
+        return textArea->tooLong(textArea->value(), HTMLTextFormControlElement::CheckDirtyFlag);
+    }
+    return false;
 }
 
 bool ValidityState::rangeUnderflow() const
 {
-    return m_control->rangeUnderflow();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (!element->hasTagName(inputTag))
+        return false;
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+    return input->rangeUnderflow(input->value());
 }
 
 bool ValidityState::rangeOverflow() const
 {
-    return m_control->rangeOverflow();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (!element->hasTagName(inputTag))
+        return false;
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+    return input->rangeOverflow(input->value());
 }
 
 bool ValidityState::stepMismatch() const
 {
-    return m_control->stepMismatch();
+    HTMLElement* element = toHTMLElement(m_control);
+    if (!element->willValidate())
+        return false;
+
+    if (!element->hasTagName(inputTag))
+        return false;
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
+    return input->stepMismatch(input->value());
 }
 
 bool ValidityState::customError() const
 {
-    return m_control->customError();
+    HTMLElement* element = toHTMLElement(m_control);
+    return element->willValidate() && !m_customErrorMessage.isEmpty();
 }
 
 bool ValidityState::valid() const
 {
-    return m_control->valid();
+    bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow()
+        || tooLong() || patternMismatch() || valueMissing() || customError();
+    return !someError;
 }
 
 } // namespace

Modified: trunk/Source/WebCore/html/ValidityState.h (116755 => 116756)


--- trunk/Source/WebCore/html/ValidityState.h	2012-05-11 12:47:57 UTC (rev 116755)
+++ trunk/Source/WebCore/html/ValidityState.h	2012-05-11 12:56:04 UTC (rev 116756)
@@ -57,7 +57,11 @@
 private:
     ValidityState(FormAssociatedElement* control) : m_control(control) { }
 
+    static bool isValidColorString(const String&);
+    static bool isValidEmailAddress(const String&);
+
     FormAssociatedElement* m_control;
+    String m_customErrorMessage;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to