Bug 1540037 - part 30: Get rid of `TextEditor::SharedOutputString()` r=m_kato

It's now used only by `HTMLEditor::Rewrap()` and it does simple thing with
`TextEditor::ComputeValueInternal()`.  So, we can make `Rewrap()` directly
do it instead.

Differential Revision: https://phabricator.services.mozilla.com/D116347
This commit is contained in:
Masayuki Nakano 2021-05-31 22:34:00 +00:00
Родитель a8f3540069
Коммит ac6b41fb7a
3 изменённых файлов: 8 добавлений и 28 удалений

Просмотреть файл

@ -2916,12 +2916,15 @@ NS_IMETHODIMP HTMLEditor::Rewrap(bool aRespectNewlines) {
}
nsAutoString current;
bool isCollapsed;
rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted |
nsIDocumentEncoder::OutputLFLineBreak,
&isCollapsed, current);
const bool isCollapsed = SelectionRef().IsCollapsed();
uint32_t flags = nsIDocumentEncoder::OutputFormatted |
nsIDocumentEncoder::OutputLFLineBreak;
if (!isCollapsed) {
flags |= nsIDocumentEncoder::OutputSelectionOnly;
}
rv = ComputeValueInternal(u"text/plain"_ns, flags, current);
if (NS_FAILED(rv)) {
NS_WARNING("TextEditor::SharedOutputString() failed");
NS_WARNING("TextEditor::ComputeValueInternal(text/plain) failed");
return EditorBase::ToGenericNSResult(rv);
}

Просмотреть файл

@ -747,22 +747,6 @@ nsresult TextEditor::InsertWithQuotationsAsSubAction(
return rv;
}
nsresult TextEditor::SharedOutputString(uint32_t aFlags, bool* aIsCollapsed,
nsAString& aResult) const {
MOZ_ASSERT(IsEditActionDataAvailable());
*aIsCollapsed = SelectionRef().IsCollapsed();
if (!*aIsCollapsed) {
aFlags |= nsIDocumentEncoder::OutputSelectionOnly;
}
// If the selection isn't collapsed, we'll use the whole document.
nsresult rv = ComputeValueInternal(u"text/plain"_ns, aFlags, aResult);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"TextEditor::ComputeValueInternal(text/plain) failed");
return rv;
}
nsresult TextEditor::SelectEntireDocument() {
MOZ_ASSERT(IsEditActionDataAvailable());
MOZ_ASSERT(!AsHTMLEditor());

Просмотреть файл

@ -556,13 +556,6 @@ class TextEditor : public EditorBase, public nsITimerCallback, public nsINamed {
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult
InsertTextFromTransferable(nsITransferable* transferable);
/**
* Shared outputstring; returns whether selection is collapsed and resulting
* string.
*/
nsresult SharedOutputString(uint32_t aFlags, bool* aIsCollapsed,
nsAString& aResult) const;
bool IsCopyToClipboardAllowedInternal() const final;
virtual already_AddRefed<Element> GetInputEventTargetElement() const override;