void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventBehavior eventBehavior, SetValueCommonOption setValueOption) { // Code elsewhere normalizes line endings added by the user via the keyboard // or pasting. We normalize line endings coming from JavaScript here. String normalizedValue = newValue.isNull() ? "" : newValue; normalizedValue.replace("\r\n", "\n"); normalizedValue.replace('\r', '\n'); // Return early because we don't want to trigger other side effects // when the value isn't changing. // FIXME: Simple early return doesn't match the Firefox ever. // Remove these lines. if (normalizedValue == value()) { if (setValueOption == SetSeletion) { setNeedsValidityCheck(); if (isFinishedParsingChildren()) { // Set the caret to the end of the text value except for initialize. unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } } return; } m_value = normalizedValue; setInnerEditorValue(m_value); if (eventBehavior == DispatchNoEvent) setLastChangeWasNotUserEdit(); updatePlaceholderVisibility(); setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); m_suggestedValue = String(); setNeedsValidityCheck(); if (isFinishedParsingChildren()) { // Set the caret to the end of the text value except for initialize. unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } notifyFormStateChanged(); switch (eventBehavior) { case DispatchChangeEvent: dispatchFormControlChangeEvent(); break; case DispatchInputAndChangeEvent: dispatchFormControlInputEvent(); dispatchFormControlChangeEvent(); break; case DispatchNoEvent: // We need to update textAsOfLastFormControlChangeEvent for |value| IDL // setter without focus because input-assist features use setValue("...", // DispatchChangeEvent) without setting focus. if (!isFocused()) setTextAsOfLastFormControlChangeEvent(normalizedValue); break; } }
void HTMLTextAreaElement::setValueCommon(const String& newValue) { m_wasModifiedByUser = false; // Code elsewhere normalizes line endings added by the user via the keyboard or pasting. // We normalize line endings coming from JavaScript here. String normalizedValue = newValue.isNull() ? "" : newValue; normalizedValue.replace("\r\n", "\n"); normalizedValue.replace('\r', '\n'); // Return early because we don't want to move the caret or trigger other side effects // when the value isn't changing. This matches Firefox behavior, at least. if (normalizedValue == value()) return; m_value = normalizedValue; setInnerTextValue(m_value); setLastChangeWasNotUserEdit(); updatePlaceholderVisibility(false); setNeedsStyleRecalc(); setFormControlValueMatchesRenderer(true); // Set the caret to the end of the text value. if (document()->focusedNode() == this) { unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } notifyFormStateChanged(); setTextAsOfLastFormControlChangeEvent(normalizedValue); }
void HTMLTextAreaElement::setValue(const String& value) { // Code elsewhere normalizes line endings added by the user via the keyboard or pasting. // We normalize line endings coming from JavaScript here. String normalizedValue = value.isNull() ? "" : value; normalizedValue.replace("\r\n", "\n"); normalizedValue.replace('\r', '\n'); // Return early because we don't want to move the caret or trigger other side effects // when the value isn't changing. This matches Firefox behavior, at least. if (normalizedValue == this->value()) return; m_value = normalizedValue; 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) { unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } setNeedsStyleRecalc(); notifyFormStateChanged(this); updateValidity(); }
void HTMLTextAreaElement::setNonDirtyValue(const String& value) { // Code elsewhere normalizes line endings added by the user via the keyboard or pasting. // We normalize line endings coming from JavaScript here. String normalizedValue = value.isNull() ? "" : value; normalizedValue.replace("\r\n", "\n"); normalizedValue.replace('\r', '\n'); // Return early because we don't want to move the caret or trigger other side effects // when the value isn't changing. This matches Firefox behavior, at least. if (normalizedValue == this->value()) return; m_value = normalizedValue; 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) { #ifdef ANDROID_ACCEPT_CHANGES_TO_FOCUSED_TEXTFIELDS // Make sure our UI side textfield changes to match the RenderTextControl android::WebViewCore::getWebViewCore(document()->view())->updateTextfield(this, false, value); #endif unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } setNeedsValidityCheck(); notifyFormStateChanged(this); }
void HTMLTextAreaElement::updateValue() const { if (valueMatchesRenderer()) return; ASSERT(renderer()); m_value = static_cast<RenderTextControl*>(renderer())->text(); setValueMatchesRenderer(); notifyFormStateChanged(this); }
void HTMLTextAreaElement::updateValue() const { if (formControlValueMatchesRenderer()) return; ASSERT(renderer()); m_value = toRenderTextControl(renderer())->text(); const_cast<HTMLTextAreaElement*>(this)->setFormControlValueMatchesRenderer(true); notifyFormStateChanged(this); }
HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) : HTMLFormControlElementWithState(tagName, document, form) , m_rows(defaultRows) , m_cols(defaultCols) , m_wrap(SoftWrap) , m_cachedSelectionStart(-1) , m_cachedSelectionEnd(-1) { ASSERT(hasTagName(textareaTag)); setValueMatchesRenderer(); notifyFormStateChanged(this); }