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

@@ -1099,6 +1099,7 @@ HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
, mNumberControlSpinnerSpinsUp(false)
, mPickerRunning(false)
, mSelectionCached(true)
, mIsPreviewEnabled(false)
{
// We are in a type=text so we now we currenty need a nsTextEditorState.
mInputData.mState =
@@ -2930,6 +2931,24 @@ HTMLInputElement::GetPreviewValue(nsAString& aValue)
}
}
NS_IMETHODIMP_(void)
HTMLInputElement::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)
HTMLInputElement::IsPreviewEnabled()
{
return mIsPreviewEnabled;
}
void
HTMLInputElement::GetDisplayFileName(nsAString& aValue) const
{