зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1501177 - Create HTMLEditor::InsertAsCitedQuotationInternal() for internal use of nsIEditorMailSupport::InsertAsCitedQuotation() r=m_kato
HTMLEditor::InsertAsCitedQuotation() is an XPCOM method, so, it shouldn't be used for internal use. Instead, there should be non-virtual method and InsertAsCitedQuotation() should use it. Differential Revision: https://phabricator.services.mozilla.com/D9501 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ad08e22419
Коммит
446538a446
|
@ -1518,6 +1518,26 @@ protected: // Shouldn't be used by friend classes
|
|||
nsresult PasteInternal(int32_t aClipboardType,
|
||||
bool aDispatchPasteEvent);
|
||||
|
||||
/**
|
||||
* InsertAsCitedQuotationInternal() inserts a <blockquote> element whose
|
||||
* cite attribute is aCitation and whose content is aQuotedText.
|
||||
* Note that this shouldn't be called when IsPlaintextEditor() is true.
|
||||
*
|
||||
* @param aQuotedText HTML source if aInsertHTML is true. Otherwise,
|
||||
* plain text. This is inserted into new <blockquote>
|
||||
* element.
|
||||
* @param aCitation cite attribute value of new <blockquote> element.
|
||||
* @param aInsertHTML true if aQuotedText should be treated as HTML
|
||||
* source.
|
||||
* false if aQuotedText should be treated as plain
|
||||
* text.
|
||||
* @param aNodeInserted [OUT] The new <blockquote> element.
|
||||
*/
|
||||
nsresult InsertAsCitedQuotationInternal(const nsAString& aQuotedText,
|
||||
const nsAString& aCitation,
|
||||
bool aInsertHTML,
|
||||
nsINode** aNodeInserted);
|
||||
|
||||
/**
|
||||
* InsertNodeIntoProperAncestorWithTransaction() attempts to insert aNode
|
||||
* into the document, at aPointToInsert. Checks with strict dtd to see if
|
||||
|
|
|
@ -1916,14 +1916,23 @@ nsresult
|
|||
HTMLEditor::InsertAsQuotation(const nsAString& aQuotedText,
|
||||
nsINode** aNodeInserted)
|
||||
{
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
if (IsPlaintextEditor()) {
|
||||
return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
nsresult rv = InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
nsAutoString citation;
|
||||
return InsertAsCitedQuotation(aQuotedText, citation, false,
|
||||
aNodeInserted);
|
||||
nsresult rv =
|
||||
InsertAsCitedQuotationInternal(aQuotedText, citation, false, aNodeInserted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Insert plaintext as a quotation, with cite marks (e.g. "> ").
|
||||
|
@ -2077,15 +2086,37 @@ HTMLEditor::InsertAsCitedQuotation(const nsAString& aQuotedText,
|
|||
bool aInsertHTML,
|
||||
nsINode** aNodeInserted)
|
||||
{
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
|
||||
// Don't let anyone insert HTML when we're in plaintext mode.
|
||||
if (IsPlaintextEditor()) {
|
||||
NS_ASSERTION(!aInsertHTML,
|
||||
"InsertAsCitedQuotation: trying to insert html into plaintext editor");
|
||||
return InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
nsresult rv = InsertAsPlaintextQuotation(aQuotedText, true, aNodeInserted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AutoPlaceholderBatch treatAsOneTransaction(*this);
|
||||
nsresult rv =
|
||||
InsertAsCitedQuotationInternal(aQuotedText, aCitation, aInsertHTML,
|
||||
aNodeInserted);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLEditor::InsertAsCitedQuotationInternal(const nsAString& aQuotedText,
|
||||
const nsAString& aCitation,
|
||||
bool aInsertHTML,
|
||||
nsINode** aNodeInserted)
|
||||
{
|
||||
MOZ_ASSERT(!IsPlaintextEditor());
|
||||
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
if (NS_WARN_IF(!selection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче