From dcc8cf2e65d1aa555cce12431a16547e66b469ee Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 27 Apr 2010 16:31:00 +0100 Subject: Merge webkit.org at r58033 : Initial merge by git Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1 --- WebCore/html/HTMLTextAreaElement.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'WebCore/html/HTMLTextAreaElement.cpp') diff --git a/WebCore/html/HTMLTextAreaElement.cpp b/WebCore/html/HTMLTextAreaElement.cpp index 633e5ec..2bfde03 100644 --- a/WebCore/html/HTMLTextAreaElement.cpp +++ b/WebCore/html/HTMLTextAreaElement.cpp @@ -90,7 +90,10 @@ const AtomicString& HTMLTextAreaElement::formControlType() const bool HTMLTextAreaElement::saveFormControlState(String& result) const { - result = value(); + String currentValue = value(); + if (currentValue == defaultValue()) + return false; + result = currentValue; return true; } @@ -170,6 +173,8 @@ bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool) if (name().isEmpty()) return false; + document()->updateLayout(); + // FIXME: It's not acceptable to ignore the HardWrap setting when there is no renderer. // While we have no evidence this has ever been a practical problem, it would be best to fix it some day. RenderTextControl* control = toRenderTextControl(renderer()); @@ -239,8 +244,8 @@ void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* return; unsigned unsignedMaxLength = static_cast(signedMaxLength); - unsigned currentLength = toRenderTextControl(renderer())->text().numGraphemeClusters(); - unsigned selectionLength = plainText(document()->frame()->selection()->selection().toNormalizedRange().get()).numGraphemeClusters(); + unsigned currentLength = numGraphemeClusters(toRenderTextControl(renderer())->text()); + unsigned selectionLength = numGraphemeClusters(plainText(document()->frame()->selection()->selection().toNormalizedRange().get())); ASSERT(currentLength >= selectionLength); unsigned baseLength = currentLength - selectionLength; unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLength - baseLength : 0; @@ -249,7 +254,7 @@ void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength) { - return proposedValue.left(proposedValue.numCharactersInGraphemeClusters(maxLength)); + return proposedValue.left(numCharactersInGraphemeClusters(proposedValue, maxLength)); } void HTMLTextAreaElement::rendererWillBeDestroyed() @@ -295,13 +300,11 @@ void HTMLTextAreaElement::setNonDirtyValue(const String& value) return; m_value = normalizedValue; + updatePlaceholderVisibility(false); + setNeedsStyleRecalc(); + setNeedsValidityCheck(); m_isDirty = false; setFormControlValueMatchesRenderer(true); - updatePlaceholderVisibility(false); - if (inDocument()) - document()->updateStyleIfNeeded(); - if (renderer()) - renderer()->updateFromElement(); // Set the caret to the end of the text value. if (document()->focusedNode() == this) { @@ -313,7 +316,6 @@ void HTMLTextAreaElement::setNonDirtyValue(const String& value) setSelectionRange(endOfString, endOfString); } - setNeedsValidityCheck(); notifyFormStateChanged(this); } @@ -388,7 +390,7 @@ bool HTMLTextAreaElement::tooLong() const int max = maxLength(); if (max < 0) return false; - return value().numGraphemeClusters() > static_cast(max); + return numGraphemeClusters(value()) > static_cast(max); } void HTMLTextAreaElement::accessKeyAction(bool) -- cgit v1.1