summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp')
-rw-r--r--src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp89
1 files changed, 20 insertions, 69 deletions
diff --git a/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp b/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp
index b5e4ced56b..3030018609 100644
--- a/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp
+++ b/src/3rdparty/webkit/WebCore/html/HTMLTextAreaElement.cpp
@@ -70,6 +70,7 @@ HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document*
, m_wrap(SoftWrap)
, m_cachedSelectionStart(-1)
, m_cachedSelectionEnd(-1)
+ , m_isDirty(false)
{
ASSERT(hasTagName(textareaTag));
setFormControlValueMatchesRenderer(true);
@@ -93,54 +94,6 @@ void HTMLTextAreaElement::restoreFormControlState(const String& state)
setDefaultValue(state);
}
-int HTMLTextAreaElement::selectionStart()
-{
- if (!renderer())
- return 0;
- if (document()->focusedNode() != this && m_cachedSelectionStart >= 0)
- return m_cachedSelectionStart;
- return toRenderTextControl(renderer())->selectionStart();
-}
-
-int HTMLTextAreaElement::selectionEnd()
-{
- if (!renderer())
- return 0;
- if (document()->focusedNode() != this && m_cachedSelectionEnd >= 0)
- return m_cachedSelectionEnd;
- return toRenderTextControl(renderer())->selectionEnd();
-}
-
-static RenderTextControl* rendererAfterUpdateLayout(HTMLTextAreaElement* element)
-{
- element->document()->updateLayoutIgnorePendingStylesheets();
- return toRenderTextControl(element->renderer());
-}
-
-void HTMLTextAreaElement::setSelectionStart(int start)
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->setSelectionStart(start);
-}
-
-void HTMLTextAreaElement::setSelectionEnd(int end)
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->setSelectionEnd(end);
-}
-
-void HTMLTextAreaElement::select()
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->select();
-}
-
-void HTMLTextAreaElement::setSelectionRange(int start, int end)
-{
- if (RenderTextControl* renderer = rendererAfterUpdateLayout(this))
- renderer->setSelectionRange(start, end);
-}
-
void HTMLTextAreaElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
setValue(defaultValue());
@@ -196,18 +149,8 @@ void HTMLTextAreaElement::parseMappedAttribute(MappedAttribute* attr)
} else if (attr->name() == alignAttr) {
// Don't map 'align' attribute. This matches what Firefox, Opera and IE do.
// See http://bugs.webkit.org/show_bug.cgi?id=7075
- } else if (attr->name() == placeholderAttr) {
- updatePlaceholderVisibility(true);
- } else if (attr->name() == onfocusAttr)
- setAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == onblurAttr)
- setAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == onselectAttr)
- setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr));
- else if (attr->name() == onchangeAttr)
- setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr));
- else
- HTMLFormControlElementWithState::parseMappedAttribute(attr);
+ } else
+ HTMLTextFormControlElement::parseMappedAttribute(attr);
}
RenderObject* HTMLTextAreaElement::createRenderer(RenderArena* arena, RenderStyle*)
@@ -231,6 +174,7 @@ bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool)
void HTMLTextAreaElement::reset()
{
setValue(defaultValue());
+ m_isDirty = false;
}
bool HTMLTextAreaElement::isKeyboardFocusable(KeyboardEvent*) const
@@ -316,6 +260,7 @@ void HTMLTextAreaElement::updateValue() const
m_value = toRenderTextControl(renderer())->text();
const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true);
notifyFormStateChanged(this);
+ m_isDirty = true;
}
String HTMLTextAreaElement::value() const
@@ -353,6 +298,7 @@ void HTMLTextAreaElement::setValue(const String& value)
setNeedsStyleRecalc();
notifyFormStateChanged(this);
+ updateValidity();
}
String HTMLTextAreaElement::defaultValue() const
@@ -409,14 +355,26 @@ int HTMLTextAreaElement::maxLength() const
return ok && value >= 0 ? value : -1;
}
-void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& exceptionCode)
+void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode& ec)
{
if (newValue < 0)
- exceptionCode = INDEX_SIZE_ERR;
+ ec = INDEX_SIZE_ERR;
else
setAttribute(maxlengthAttr, String::number(newValue));
}
+bool HTMLTextAreaElement::tooLong() const
+{
+ // Return false for the default value even if it is longer than maxLength.
+ if (!m_isDirty)
+ return false;
+
+ int max = maxLength();
+ if (max < 0)
+ return false;
+ return value().length() > static_cast<unsigned>(max);
+}
+
void HTMLTextAreaElement::accessKeyAction(bool)
{
focus();
@@ -442,13 +400,6 @@ void HTMLTextAreaElement::setRows(int rows)
setAttribute(rowsAttr, String::number(rows));
}
-VisibleSelection HTMLTextAreaElement::selection() const
-{
- if (!renderer() || m_cachedSelectionStart < 0 || m_cachedSelectionEnd < 0)
- return VisibleSelection();
- return toRenderTextControl(renderer())->selection(m_cachedSelectionStart, m_cachedSelectionEnd);
-}
-
bool HTMLTextAreaElement::shouldUseInputMethod() const
{
return true;