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 WMLInputElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == HTMLNames::nameAttr) m_data.setName(parseValueForbiddingVariableReferences(attr->value())); else if (attr->name() == HTMLNames::typeAttr) { String type = parseValueForbiddingVariableReferences(attr->value()); m_isPasswordField = (type == "password"); } else if (attr->name() == HTMLNames::valueAttr) { // We only need to setChanged if the form is looking at the default value right now. if (m_data.value().isNull()) setNeedsStyleRecalc(); setFormControlValueMatchesRenderer(false); } else if (attr->name() == HTMLNames::maxlengthAttr) InputElement::parseMaxLengthAttribute(m_data, this, this, attr); else if (attr->name() == HTMLNames::sizeAttr) InputElement::parseSizeAttribute(m_data, this, attr); else if (attr->name() == WMLNames::formatAttr) m_formatMask = validateInputMask(parseValueForbiddingVariableReferences(attr->value())); else if (attr->name() == WMLNames::emptyokAttr) m_isEmptyOk = (attr->value() == "true"); else WMLElement::parseMappedAttribute(attr); // FIXME: Handle 'accesskey' attribute // FIXME: Handle 'tabindex' attribute // FIXME: Handle 'title' attribute }
void HTMLTextFormControlElement::setInnerTextValue(const String& value) { TextControlInnerTextElement* innerText = innerTextElement(); if (!innerText) return; ASSERT(isTextFormControl()); String previousValue = innerTextValueFrom(*innerText); bool textIsChanged = value != previousValue; if (textIsChanged || !innerText->hasChildNodes()) { #if HAVE(ACCESSIBILITY) && !PLATFORM(COCOA) if (textIsChanged && renderer()) { if (AXObjectCache* cache = document().existingAXObjectCache()) cache->postNotification(this, AXObjectCache::AXValueChanged, TargetObservableParent); } #endif innerText->setInnerText(value, ASSERT_NO_EXCEPTION); if (value.endsWith('\n') || value.endsWith('\r')) innerText->appendChild(HTMLBRElement::create(document()), ASSERT_NO_EXCEPTION); #if HAVE(ACCESSIBILITY) && PLATFORM(COCOA) if (textIsChanged && renderer()) { if (AXObjectCache* cache = document().existingAXObjectCache()) cache->postTextReplacementNotification(this, AXTextEditTypeDelete, previousValue, AXTextEditTypeInsert, value, VisiblePosition(Position(this, Position::PositionIsBeforeAnchor))); } #endif } setFormControlValueMatchesRenderer(true); }
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); }
HTMLTextAreaElement::HTMLTextAreaElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) : HTMLTextFormControlElement(tagName, document, form) , m_rows(defaultRows) , m_cols(defaultCols) , m_wrap(SoftWrap) , m_isDirty(false) , m_wasModifiedByUser(false) { ASSERT(hasTagName(textareaTag)); setFormControlValueMatchesRenderer(true); }
void HTMLTextAreaElement::subtreeHasChanged() { setChangedSinceLastFormControlChangeEvent(true); setFormControlValueMatchesRenderer(false); setNeedsValidityCheck(); if (!focused()) return; // When typing in a textarea, childrenChanged is not called, so we need to force the directionality check. calculateAndAdjustDirectionality(); }
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)); setFormControlValueMatchesRenderer(true); notifyFormStateChanged(this); }
void HTMLTextAreaElement::subtreeHasChanged() { setChangedSinceLastFormControlChangeEvent(true); setFormControlValueMatchesRenderer(false); updateValidity(); if (!focused()) return; if (Frame* frame = document().frame()) frame->editor().textDidChangeInTextArea(this); // When typing in a textarea, childrenChanged is not called, so we need to force the directionality check. calculateAndAdjustDirectionality(); }
void WMLInputElement::setValue(const String& value, bool) { setFormControlValueMatchesRenderer(false); m_data.setValue(constrainValue(value)); if (inDocument()) document()->updateStyleIfNeeded(); if (renderer()) renderer()->updateFromElement(); setNeedsStyleRecalc(); unsigned max = m_data.value().length(); if (document()->focusedNode() == this) InputElement::updateSelectionRange(this, this, max, max); else cacheSelection(max, max); InputElement::notifyFormStateChanged(this); }
void HTMLTextFormControlElement::setInnerTextValue(const String& value) { if (!isTextFormControl()) return; bool textIsChanged = value != innerTextValue(); if (textIsChanged || !innerTextElement()->hasChildNodes()) { if (textIsChanged && renderer()) { if (AXObjectCache* cache = document().existingAXObjectCache()) cache->postNotification(this, AXObjectCache::AXValueChanged, TargetObservableParent); } innerTextElement()->setInnerText(value, ASSERT_NO_EXCEPTION); if (value.endsWith('\n') || value.endsWith('\r')) innerTextElement()->appendChild(HTMLBRElement::create(document()), ASSERT_NO_EXCEPTION); } setFormControlValueMatchesRenderer(true); }
void HTMLTextFormControlElement::setInnerTextValue(const String& value) { if (!isTextFormControl()) return; bool textIsChanged = value != innerTextValue(); if (textIsChanged || !innerTextElement()->hasChildNodes()) { if (textIsChanged && document() && renderer() && AXObjectCache::accessibilityEnabled()) document()->axObjectCache()->postNotification(this, AXObjectCache::AXValueChanged, false); ExceptionCode ec = 0; innerTextElement()->setInnerText(value, ec); ASSERT(!ec); if (value.endsWith('\n') || value.endsWith('\r')) { innerTextElement()->appendChild(HTMLBRElement::create(document()), ec); ASSERT(!ec); } } setFormControlValueMatchesRenderer(true); }
void WMLInputElement::detach() { WMLElement::detach(); setFormControlValueMatchesRenderer(false); }