Bug 1340483 - Part 3. Enable preview function only when input is marked as autofill field. r=heycam

MozReview-Commit-ID: FFqYJ3icRd7
This commit is contained in:
Ray Lin
2017-03-22 16:55:56 +08:00
parent f4d11417f9
commit d37849aaa3
8 changed files with 68 additions and 4 deletions

View File

@@ -62,6 +62,7 @@ HTMLTextAreaElement::HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo
mDisabledChanged(false),
mCanShowInvalidUI(true),
mCanShowValidUI(true),
mIsPreviewEnabled(false),
mState(this)
{
AddMutationObserver(this);
@@ -345,6 +346,24 @@ HTMLTextAreaElement::GetPreviewValue(nsAString& aValue)
mState.GetPreviewText(aValue);
}
NS_IMETHODIMP_(void)
HTMLTextAreaElement::EnablePreview()
{
if (mIsPreviewEnabled) {
return;
}
mIsPreviewEnabled = true;
// Reconstruct the frame to append an anonymous preview node
nsLayoutUtils::PostRestyleEvent(this, nsRestyleHint(0), nsChangeHint_ReconstructFrame);
}
NS_IMETHODIMP_(bool)
HTMLTextAreaElement::IsPreviewEnabled()
{
return mIsPreviewEnabled;
}
nsresult
HTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
uint32_t aFlags)