nsresult HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { if (aVisitor.mEvent->message == NS_FORM_SELECTED) { mHandlingSelect = false; } if (aVisitor.mEvent->message == NS_FOCUS_CONTENT || aVisitor.mEvent->message == NS_BLUR_CONTENT) { if (aVisitor.mEvent->message == NS_FOCUS_CONTENT) { // If the invalid UI is shown, we should show it while focusing (and // update). Otherwise, we should not. GetValueInternal(mFocusedValue, true); mCanShowInvalidUI = !IsValid() && ShouldShowValidityUI(); // If neither invalid UI nor valid UI is shown, we shouldn't show the valid // UI while typing. mCanShowValidUI = ShouldShowValidityUI(); } else { // NS_BLUR_CONTENT mCanShowInvalidUI = true; mCanShowValidUI = true; } UpdateState(true); } // Reset the flag for other content besides this text field aVisitor.mEvent->mFlags.mNoContentDispatch = ((aVisitor.mItemFlags & NS_NO_CONTENT_DISPATCH) != 0); return NS_OK; }
EventStates HTMLTextAreaElement::IntrinsicState() const { EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState(); if (HasAttr(kNameSpaceID_None, nsGkAtoms::required)) { state |= NS_EVENT_STATE_REQUIRED; } else { state |= NS_EVENT_STATE_OPTIONAL; } if (IsCandidateForConstraintValidation()) { if (IsValid()) { state |= NS_EVENT_STATE_VALID; } else { state |= NS_EVENT_STATE_INVALID; // :-moz-ui-invalid always apply if the element suffers from a custom // error and never applies if novalidate is set on the form owner. if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) && (GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) || (mCanShowInvalidUI && ShouldShowValidityUI()))) { state |= NS_EVENT_STATE_MOZ_UI_INVALID; } } // :-moz-ui-valid applies if all the following are true: // 1. The element is not focused, or had either :-moz-ui-valid or // :-moz-ui-invalid applying before it was focused ; // 2. The element is either valid or isn't allowed to have // :-moz-ui-invalid applying ; // 3. The element has no form owner or its form owner doesn't have the // novalidate attribute set ; // 4. The element has already been modified or the user tried to submit the // form owner while invalid. if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) && (mCanShowValidUI && ShouldShowValidityUI() && (IsValid() || (state.HasState(NS_EVENT_STATE_MOZ_UI_INVALID) && !mCanShowInvalidUI)))) { state |= NS_EVENT_STATE_MOZ_UI_VALID; } } if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) && IsValueEmpty()) { state |= NS_EVENT_STATE_PLACEHOLDERSHOWN; } return state; }