Bug 1340483 - Part 2. Expose chrome-only previewValue attribute. r=baku,heycam

MozReview-Commit-ID: BCu0vXVm6wj
This commit is contained in:
Ray Lin
2017-03-21 00:08:01 +08:00
parent 78ff382026
commit f4d11417f9
9 changed files with 89 additions and 0 deletions

View File

@@ -2722,6 +2722,37 @@ nsTextEditorState::UpdatePlaceholderText(bool aNotify)
mPlaceholderDiv->GetFirstChild()->SetText(placeholderValue, aNotify);
}
void
nsTextEditorState::SetPreviewText(const nsAString& aValue, bool aNotify)
{
MOZ_ASSERT(mPreviewDiv, "This function should not be called if "
"mPreviewDiv isn't set");
// If we don't have a preview div, there's nothing to do.
if (!mPreviewDiv)
return;
nsAutoString previewValue(aValue);
nsContentUtils::RemoveNewlines(previewValue);
MOZ_ASSERT(mPreviewDiv->GetFirstChild(), "preview div has no child");
mPreviewDiv->GetFirstChild()->SetText(previewValue, aNotify);
}
void
nsTextEditorState::GetPreviewText(nsAString& aValue)
{
// If we don't have a preview div, there's nothing to do.
if (!mPreviewDiv)
return;
MOZ_ASSERT(mPreviewDiv->GetFirstChild(), "preview div has no child");
const nsTextFragment *text = mPreviewDiv->GetFirstChild()->GetText();
aValue.Truncate();
text->AppendTo(aValue);
}
void
nsTextEditorState::UpdatePlaceholderVisibility(bool aNotify)
{