diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-18 14:03:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-18 14:03:11 +0200 |
commit | 8d473cf9743f1d30a16a27114e93bd5af5648d23 (patch) | |
tree | cdca40d0353886b3ca52f33a2d7b8f1c0011aafc /Source/WebCore/html/HTMLTextAreaElement.cpp | |
parent | 1b914638db989aaa98631a1c1e02c7b2d44805d8 (diff) | |
download | qtwebkit-8d473cf9743f1d30a16a27114e93bd5af5648d23.tar.gz |
Imported WebKit commit 1350e72f7345ced9da2bd9980deeeb5a8d62fab4 (http://svn.webkit.org/repository/webkit/trunk@117578)
Weekly snapshot
Diffstat (limited to 'Source/WebCore/html/HTMLTextAreaElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLTextAreaElement.cpp | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/Source/WebCore/html/HTMLTextAreaElement.cpp b/Source/WebCore/html/HTMLTextAreaElement.cpp index 8257d0f93..1652c8911 100644 --- a/Source/WebCore/html/HTMLTextAreaElement.cpp +++ b/Source/WebCore/html/HTMLTextAreaElement.cpp @@ -37,6 +37,7 @@ #include "FormDataList.h" #include "Frame.h" #include "HTMLNames.h" +#include "LocalizedStrings.h" #include "RenderTextControlMultiLine.h" #include "ShadowRoot.h" #include "Text.h" @@ -132,9 +133,9 @@ bool HTMLTextAreaElement::isPresentationAttribute(const QualifiedName& name) con return HTMLTextFormControlElement::isPresentationAttribute(name); } -void HTMLTextAreaElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* style) +void HTMLTextAreaElement::collectStyleForAttribute(const Attribute& attribute, StylePropertySet* style) { - if (attr->name() == wrapAttr) { + if (attribute.name() == wrapAttr) { if (shouldWrapText()) { addPropertyToAttributeStyle(style, CSSPropertyWhiteSpace, CSSValuePreWrap); addPropertyToAttributeStyle(style, CSSPropertyWordWrap, CSSValueBreakWord); @@ -143,13 +144,13 @@ void HTMLTextAreaElement::collectStyleForAttribute(Attribute* attr, StylePropert addPropertyToAttributeStyle(style, CSSPropertyWordWrap, CSSValueNormal); } } else - HTMLTextFormControlElement::collectStyleForAttribute(attr, style); + HTMLTextFormControlElement::collectStyleForAttribute(attribute, style); } -void HTMLTextAreaElement::parseAttribute(Attribute* attr) +void HTMLTextAreaElement::parseAttribute(const Attribute& attribute) { - if (attr->name() == rowsAttr) { - int rows = attr->value().toInt(); + if (attribute.name() == rowsAttr) { + int rows = attribute.value().toInt(); if (rows <= 0) rows = defaultRows; if (m_rows != rows) { @@ -157,8 +158,8 @@ void HTMLTextAreaElement::parseAttribute(Attribute* attr) if (renderer()) renderer()->setNeedsLayoutAndPrefWidthsRecalc(); } - } else if (attr->name() == colsAttr) { - int cols = attr->value().toInt(); + } else if (attribute.name() == colsAttr) { + int cols = attribute.value().toInt(); if (cols <= 0) cols = defaultCols; if (m_cols != cols) { @@ -166,13 +167,13 @@ void HTMLTextAreaElement::parseAttribute(Attribute* attr) if (renderer()) renderer()->setNeedsLayoutAndPrefWidthsRecalc(); } - } else if (attr->name() == wrapAttr) { + } else if (attribute.name() == wrapAttr) { // The virtual/physical values were a Netscape extension of HTML 3.0, now deprecated. // The soft/hard /off values are a recommendation for HTML 4 extension by IE and NS 4. WrapMethod wrap; - if (equalIgnoringCase(attr->value(), "physical") || equalIgnoringCase(attr->value(), "hard") || equalIgnoringCase(attr->value(), "on")) + if (equalIgnoringCase(attribute.value(), "physical") || equalIgnoringCase(attribute.value(), "hard") || equalIgnoringCase(attribute.value(), "on")) wrap = HardWrap; - else if (equalIgnoringCase(attr->value(), "off")) + else if (equalIgnoringCase(attribute.value(), "off")) wrap = NoWrap; else wrap = SoftWrap; @@ -181,12 +182,12 @@ void HTMLTextAreaElement::parseAttribute(Attribute* attr) if (renderer()) renderer()->setNeedsLayoutAndPrefWidthsRecalc(); } - } else if (attr->name() == accesskeyAttr) { + } else if (attribute.name() == accesskeyAttr) { // ignore for the moment - } else if (attr->name() == maxlengthAttr) + } else if (attribute.name() == maxlengthAttr) setNeedsValidityCheck(); else - HTMLTextFormControlElement::parseAttribute(attr); + HTMLTextFormControlElement::parseAttribute(attribute); } RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle*) @@ -423,6 +424,33 @@ void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& ec) 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 |