mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1762115 - part 4: Make SplitNodeTransaction::DoTransaction()
stop touching selection r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D144647
This commit is contained in:
parent
8417767d09
commit
2fc91917b4
@ -4383,6 +4383,21 @@ SplitNodeResult HTMLEditor::SplitNodeWithTransaction(
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::DoTransactionInternal() failed");
|
||||
|
||||
if (NS_SUCCEEDED(rv) && AllowsTransactionsToChangeSelection()) {
|
||||
if (const nsIContent* previousContent = transaction->GetNewContent()) {
|
||||
const auto pointToPutCaret = EditorRawDOMPoint::AtEndOf(*previousContent);
|
||||
if (MOZ_LIKELY(pointToPutCaret.IsSet())) {
|
||||
rv = CollapseSelectionTo(pointToPutCaret);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"EditorBase::CollapseSelectionTo() failed");
|
||||
} else {
|
||||
NS_WARNING(
|
||||
"The previous node of split point was removed by the web app");
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> newContent = transaction->GetNewContent();
|
||||
nsCOMPtr<nsIContent> splitContent = transaction->GetSplitContent();
|
||||
if (MOZ_LIKELY(NS_SUCCEEDED(rv) && newContent && splitContent)) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/ToString.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION, etc.
|
||||
#include "nsError.h" // for NS_ERROR_NOT_INITIALIZED, etc.
|
||||
@ -120,21 +119,7 @@ NS_IMETHODIMP SplitNodeTransaction::DoTransaction() {
|
||||
NS_WARNING("SplitNodeTransaction::DoTransactionInternal() failed");
|
||||
return EditorBase::ToGenericNSResult(splitNodeResult.Rv());
|
||||
}
|
||||
|
||||
if (!htmlEditor->AllowsTransactionsToChangeSelection()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_WARNING_ASSERTION(
|
||||
!htmlEditor->Destroyed(),
|
||||
"The editor has gone but SplitNodeTransaction keeps trying to modify "
|
||||
"Selection");
|
||||
MOZ_DIAGNOSTIC_ASSERT(splitNodeResult.GetNewContent());
|
||||
htmlEditor->CollapseSelectionTo(
|
||||
EditorRawDOMPoint::AtEndOf(*splitNodeResult.GetNewContent()), error);
|
||||
NS_WARNING_ASSERTION(!error.Failed(),
|
||||
"EditorBase::CollapseSelectionTo() failed");
|
||||
return error.StealNSResult();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
SplitNodeResult SplitNodeTransaction::DoTransactionInternal(
|
||||
|
Loading…
Reference in New Issue
Block a user