void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type) { if (supportsPlaceholder()) updatePlaceholderVisibility(false); handleBlurEvent(); HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type); }
void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities) { if (supportsPlaceholder()) updatePlaceholderVisibility(); handleBlurEvent(); HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type, sourceCapabilities); }
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::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 HTMLTextFormControlElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode) { if (supportsPlaceholder()) updatePlaceholderVisibility(false); handleBlurEvent(); HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode); }
void HTMLTextAreaElement::subtreeHasChanged() { #if DCHECK_IS_ON() // The innerEditor should have either Text nodes or a placeholder break // element. If we see other nodes, it's a bug in editing code and we should // fix it. Element* innerEditor = innerEditorElement(); for (Node& node : NodeTraversal::descendantsOf(*innerEditor)) { if (node.isTextNode()) continue; DCHECK(isHTMLBRElement(node)); DCHECK_EQ(&node, innerEditor->lastChild()); } #endif addPlaceholderBreakElementIfNecessary(); setChangedSinceLastFormControlChangeEvent(true); m_valueIsUpToDate = false; setNeedsValidityCheck(); setAutofilled(false); updatePlaceholderVisibility(); if (!isFocused()) return; // When typing in a textarea, childrenChanged is not called, so we need to // force the directionality check. calculateAndAdjustDirectionality(); DCHECK(document().isActive()); document().frameHost()->chromeClient().didChangeValueInTextField(*this); }
void HTMLTextFormControlElement::dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) { if (supportsPlaceholder()) updatePlaceholderVisibility(); handleBlurEvent(); HTMLFormControlElementWithState::dispatchBlurEvent(WTF::move(newFocusedElement)); }
void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, FocusType type) { if (supportsPlaceholder()) updatePlaceholderVisibility(false); handleFocusEvent(oldFocusedElement, type); HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type); }
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 HTMLTextFormControlElement::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection direction) { if (supportsPlaceholder()) updatePlaceholderVisibility(); handleFocusEvent(oldFocusedElement.get(), direction); HTMLFormControlElementWithState::dispatchFocusEvent(WTF::move(oldFocusedElement), direction); }
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 HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == placeholderAttr) { updatePlaceholderVisibility(true); UseCounter::count(document(), UseCounter::PlaceholderAttribute); } else HTMLFormControlElementWithState::parseAttribute(name, value); }
void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == placeholderAttr) { updatePlaceholderText(); updatePlaceholderVisibility(); } else HTMLFormControlElementWithState::parseAttribute(name, value); }
void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == placeholderAttr) updatePlaceholderVisibility(true); else if (name == onselectAttr) setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, name, value)); else if (name == onchangeAttr) setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, name, value)); else HTMLFormControlElementWithState::parseAttribute(name, value); }
void HTMLTextAreaElement::setSuggestedValue(const String& value) { m_suggestedValue = value; if (!value.isNull()) setInnerEditorValue(m_suggestedValue); else setInnerEditorValue(m_value); updatePlaceholderVisibility(); setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( StyleChangeReason::ControlValue)); }
void HTMLTextFormControlElement::parseAttribute(Attribute* attr) { if (attr->name() == placeholderAttr) updatePlaceholderVisibility(true); else if (attr->name() == onselectAttr) setAttributeEventListener(eventNames().selectEvent, createAttributeEventListener(this, attr)); else if (attr->name() == onchangeAttr) setAttributeEventListener(eventNames().changeEvent, createAttributeEventListener(this, attr)); else HTMLFormControlElementWithState::parseAttribute(attr); }
void HTMLTextFormControlElement::parseAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& value) { if (name == autocapitalizeAttr) UseCounter::count(document(), UseCounter::AutocapitalizeAttribute); if (name == placeholderAttr) { updatePlaceholderText(); updatePlaceholderVisibility(); UseCounter::count(document(), UseCounter::PlaceholderAttribute); } else { HTMLFormControlElementWithState::parseAttribute(name, oldValue, value); } }
void HTMLTextAreaElement::subtreeHasChanged() { setChangedSinceLastFormControlChangeEvent(true); m_valueIsUpToDate = false; setNeedsValidityCheck(); setAutofilled(false); updatePlaceholderVisibility(); if (!focused()) return; // When typing in a textarea, childrenChanged is not called, so we need to force the directionality check. calculateAndAdjustDirectionality(); ASSERT(document().isActive()); document().frameHost()->chromeClient().didChangeValueInTextField(*this); }
void HTMLTextFormControlElement::showPlaceholderIfNecessary() { updatePlaceholderVisibility(false); }