Bug 1859245 - part 3: Make `JoinNodesTransaction` and `SplitNodeTransaction` handle only the new direction mode r=m_kato

Depends on D191606

Differential Revision: https://phabricator.services.mozilla.com/D191607
This commit is contained in:
Masayuki Nakano 2023-10-27 01:57:29 +00:00
Родитель 22a3483011
Коммит 982ddb7a9a
10 изменённых файлов: 41 добавлений и 148 удалений

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

@ -6751,8 +6751,8 @@ void EditorBase::TopLevelEditSubActionData::WillDeleteContent(
} }
void EditorBase::TopLevelEditSubActionData::DidSplitContent( void EditorBase::TopLevelEditSubActionData::DidSplitContent(
EditorBase& aEditorBase, nsIContent& aSplitContent, nsIContent& aNewContent, EditorBase& aEditorBase, nsIContent& aSplitContent,
SplitNodeDirection aSplitNodeDirection) { nsIContent& aNewContent) {
MOZ_ASSERT(aEditorBase.AsHTMLEditor()); MOZ_ASSERT(aEditorBase.AsHTMLEditor());
if (!aEditorBase.mInitSucceeded || aEditorBase.Destroyed()) { if (!aEditorBase.mInitSucceeded || aEditorBase.Destroyed()) {
@ -6763,14 +6763,9 @@ void EditorBase::TopLevelEditSubActionData::DidSplitContent(
return; // Temporarily disabled by edit sub-action handler. return; // Temporarily disabled by edit sub-action handler.
} }
DebugOnly<nsresult> rvIgnored = DebugOnly<nsresult> rvIgnored = AddRangeToChangedRange(
aSplitNodeDirection == SplitNodeDirection::LeftNodeIsNewOne *aEditorBase.AsHTMLEditor(), EditorRawDOMPoint::AtEndOf(aSplitContent),
? AddRangeToChangedRange(*aEditorBase.AsHTMLEditor(), EditorRawDOMPoint::AtEndOf(aNewContent));
EditorRawDOMPoint(&aNewContent, 0),
EditorRawDOMPoint(&aSplitContent, 0))
: AddRangeToChangedRange(*aEditorBase.AsHTMLEditor(),
EditorRawDOMPoint::AtEndOf(aSplitContent),
EditorRawDOMPoint::AtEndOf(aNewContent));
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored), NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
"TopLevelEditSubActionData::AddRangeToChangedRange() " "TopLevelEditSubActionData::AddRangeToChangedRange() "
"failed, but ignored"); "failed, but ignored");

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

@ -849,8 +849,7 @@ class EditorBase : public nsIEditor,
void WillDeleteContent(EditorBase& aEditorBase, void WillDeleteContent(EditorBase& aEditorBase,
nsIContent& aRemovingContent); nsIContent& aRemovingContent);
void DidSplitContent(EditorBase& aEditorBase, nsIContent& aSplitContent, void DidSplitContent(EditorBase& aEditorBase, nsIContent& aSplitContent,
nsIContent& aNewContent, nsIContent& aNewContent);
SplitNodeDirection aSplitNodeDirection);
void DidJoinContents(EditorBase& aEditorBase, void DidJoinContents(EditorBase& aEditorBase,
const EditorRawDOMPoint& aJoinedPoint); const EditorRawDOMPoint& aJoinedPoint);
void DidInsertText(EditorBase& aEditorBase, void DidInsertText(EditorBase& aEditorBase,

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

@ -5109,8 +5109,8 @@ Result<SplitNodeResult, nsresult> HTMLEditor::SplitNodeWithTransaction(
if (NS_WARN_IF(!newContent) || NS_WARN_IF(!splitContent)) { if (NS_WARN_IF(!newContent) || NS_WARN_IF(!splitContent)) {
return Err(NS_ERROR_FAILURE); return Err(NS_ERROR_FAILURE);
} }
TopLevelEditSubActionDataRef().DidSplitContent( TopLevelEditSubActionDataRef().DidSplitContent(*this, *splitContent,
*this, *splitContent, *newContent, transaction->GetSplitNodeDirection()); *newContent);
if (NS_WARN_IF(!newContent->IsInComposedDoc()) || if (NS_WARN_IF(!newContent->IsInComposedDoc()) ||
NS_WARN_IF(!splitContent->IsInComposedDoc())) { NS_WARN_IF(!splitContent->IsInComposedDoc())) {
return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE); return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE);
@ -5554,8 +5554,7 @@ void HTMLEditor::DidJoinNodesTransaction(
mTextServicesDocument) { mTextServicesDocument) {
textServicesDocument->DidJoinContents( textServicesDocument->DidJoinContents(
aTransaction.CreateJoinedPoint<EditorRawDOMPoint>(), aTransaction.CreateJoinedPoint<EditorRawDOMPoint>(),
*aTransaction.GetRemovedContent(), *aTransaction.GetRemovedContent());
aTransaction.GetJoinNodesDirection());
} }
} }
@ -5563,9 +5562,7 @@ void HTMLEditor::DidJoinNodesTransaction(
for (auto& listener : mActionListeners.Clone()) { for (auto& listener : mActionListeners.Clone()) {
DebugOnly<nsresult> rvIgnored = listener->DidJoinContents( DebugOnly<nsresult> rvIgnored = listener->DidJoinContents(
aTransaction.CreateJoinedPoint<EditorRawDOMPoint>(), aTransaction.CreateJoinedPoint<EditorRawDOMPoint>(),
aTransaction.GetRemovedContent(), aTransaction.GetRemovedContent());
aTransaction.GetJoinNodesDirection() ==
JoinNodesDirection::LeftNodeIntoRightNode);
NS_WARNING_ASSERTION( NS_WARNING_ASSERTION(
NS_SUCCEEDED(rvIgnored), NS_SUCCEEDED(rvIgnored),
"nsIEditActionListener::DidJoinContents() failed, but ignored"); "nsIEditActionListener::DidJoinContents() failed, but ignored");

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

@ -5,10 +5,9 @@
#include "JoinNodesTransaction.h" #include "JoinNodesTransaction.h"
#include "EditorDOMPoint.h" // for EditorDOMPoint, etc. #include "EditorDOMPoint.h" // for EditorDOMPoint, etc.
#include "HTMLEditHelpers.h" // for SplitNodeResult #include "HTMLEditHelpers.h" // for SplitNodeResult
#include "JoinSplitNodeDirection.h" // JoinNodesDirection #include "HTMLEditor.h" // for HTMLEditor
#include "HTMLEditor.h" // for HTMLEditor
#include "HTMLEditorInlines.h" #include "HTMLEditorInlines.h"
#include "HTMLEditUtils.h" #include "HTMLEditUtils.h"
@ -42,14 +41,8 @@ JoinNodesTransaction::JoinNodesTransaction(HTMLEditor& aHTMLEditor,
nsIContent& aLeftContent, nsIContent& aLeftContent,
nsIContent& aRightContent) nsIContent& aRightContent)
: mHTMLEditor(&aHTMLEditor), : mHTMLEditor(&aHTMLEditor),
mRemovedContent(aHTMLEditor.GetJoinNodesDirection() == mRemovedContent(&aRightContent),
JoinNodesDirection::LeftNodeIntoRightNode mKeepingContent(&aLeftContent) {
? &aLeftContent
: &aRightContent),
mKeepingContent(aHTMLEditor.GetJoinNodesDirection() ==
JoinNodesDirection::LeftNodeIntoRightNode
? &aRightContent
: &aLeftContent) {
// printf("JoinNodesTransaction size: %zu\n", sizeof(JoinNodesTransaction)); // printf("JoinNodesTransaction size: %zu\n", sizeof(JoinNodesTransaction));
static_assert(sizeof(JoinNodesTransaction) <= 64, static_assert(sizeof(JoinNodesTransaction) <= 64,
"Transaction classes may be created a lot and may be alive " "Transaction classes may be created a lot and may be alive "
@ -71,9 +64,7 @@ std::ostream& operator<<(std::ostream& aStream,
aStream << " (" << *aTransaction.mKeepingContent << ")"; aStream << " (" << *aTransaction.mKeepingContent << ")";
} }
aStream << ", mJoinedOffset=" << aTransaction.mJoinedOffset aStream << ", mJoinedOffset=" << aTransaction.mJoinedOffset
<< ", mHTMLEditor=" << aTransaction.mHTMLEditor.get() << ", mHTMLEditor=" << aTransaction.mHTMLEditor.get() << " }";
<< ", GetJoinNodesDirection()="
<< aTransaction.GetJoinNodesDirection() << " }";
return aStream; return aStream;
} }
@ -84,16 +75,6 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodesTransaction, EditTransactionBase,
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinNodesTransaction) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(JoinNodesTransaction)
NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase) NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
SplitNodeDirection JoinNodesTransaction::GetSplitNodeDirection() const {
return MOZ_LIKELY(mHTMLEditor) ? mHTMLEditor->GetSplitNodeDirection()
: SplitNodeDirection::LeftNodeIsNewOne;
}
JoinNodesDirection JoinNodesTransaction::GetJoinNodesDirection() const {
return MOZ_LIKELY(mHTMLEditor) ? mHTMLEditor->GetJoinNodesDirection()
: JoinNodesDirection::LeftNodeIntoRightNode;
}
bool JoinNodesTransaction::CanDoIt() const { bool JoinNodesTransaction::CanDoIt() const {
if (NS_WARN_IF(!mKeepingContent) || NS_WARN_IF(!mRemovedContent) || if (NS_WARN_IF(!mKeepingContent) || NS_WARN_IF(!mRemovedContent) ||
NS_WARN_IF(!mHTMLEditor) || NS_WARN_IF(!mHTMLEditor) ||
@ -140,22 +121,16 @@ nsresult JoinNodesTransaction::DoTransactionInternal(
// For now, setting mJoinedOffset to removed content length so that // For now, setting mJoinedOffset to removed content length so that
// CreateJoinedPoint returns a point in mKeepingContent whose offset is // CreateJoinedPoint returns a point in mKeepingContent whose offset is
// the result if all content in mRemovedContent are moved to start or end of // the result if all content in mRemovedContent are moved to start or end of
// mKeepingContent without any intervation. The offset will be adjusted // mKeepingContent without any intervention. The offset will be adjusted
// below. // below.
mJoinedOffset = mJoinedOffset = mKeepingContent->Length();
GetJoinNodesDirection() == JoinNodesDirection::LeftNodeIntoRightNode
? mRemovedContent->Length()
: mKeepingContent->Length();
const OwningNonNull<HTMLEditor> htmlEditor = *mHTMLEditor; const OwningNonNull<HTMLEditor> htmlEditor = *mHTMLEditor;
const OwningNonNull<nsIContent> removingContent = *mRemovedContent; const OwningNonNull<nsIContent> removingContent = *mRemovedContent;
const OwningNonNull<nsIContent> keepingContent = *mKeepingContent; const OwningNonNull<nsIContent> keepingContent = *mKeepingContent;
nsresult rv; nsresult rv;
// Let's try to get actual joined point with the tacker. // Let's try to get actual joined point with the tacker.
EditorDOMPoint joinNodesPoint = auto joinNodesPoint = EditorDOMPoint::AtEndOf(keepingContent);
GetJoinNodesDirection() == JoinNodesDirection::LeftNodeIntoRightNode
? EditorDOMPoint(keepingContent, 0u)
: EditorDOMPoint::AtEndOf(keepingContent);
{ {
AutoTrackDOMPoint trackJoinNodePoint(htmlEditor->RangeUpdaterRef(), AutoTrackDOMPoint trackJoinNodePoint(htmlEditor->RangeUpdaterRef(),
&joinNodesPoint); &joinNodesPoint);

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

@ -60,11 +60,6 @@ class JoinNodesTransaction final : public EditTransactionBase {
MOZ_CAN_RUN_SCRIPT NS_IMETHOD RedoTransaction() override; MOZ_CAN_RUN_SCRIPT NS_IMETHOD RedoTransaction() override;
// Note that we don't support join/split node direction switching per
// transaction.
[[nodiscard]] SplitNodeDirection GetSplitNodeDirection() const;
[[nodiscard]] JoinNodesDirection GetJoinNodesDirection() const;
/** /**
* GetExistingContent() and GetRemovedContent() never returns nullptr * GetExistingContent() and GetRemovedContent() never returns nullptr
* unless the cycle collector clears them out. * unless the cycle collector clears them out.

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

@ -10,8 +10,7 @@
#include "HTMLEditor.h" // for HTMLEditor #include "HTMLEditor.h" // for HTMLEditor
#include "HTMLEditorInlines.h" #include "HTMLEditorInlines.h"
#include "HTMLEditUtils.h" #include "HTMLEditUtils.h"
#include "JoinSplitNodeDirection.h" // for SplitNodeDirection #include "SelectionState.h" // for AutoTrackDOMPoint and RangeUpdater
#include "SelectionState.h" // for AutoTrackDOMPoint and RangeUpdater
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "mozilla/Maybe.h" #include "mozilla/Maybe.h"
@ -71,9 +70,7 @@ std::ostream& operator<<(std::ostream& aStream,
aStream << " (" << *aTransaction.mSplitContent << ")"; aStream << " (" << *aTransaction.mSplitContent << ")";
} }
aStream << ", mSplitOffset=" << aTransaction.mSplitOffset aStream << ", mSplitOffset=" << aTransaction.mSplitOffset
<< ", mHTMLEditor=" << aTransaction.mHTMLEditor.get() << ", mHTMLEditor=" << aTransaction.mHTMLEditor.get() << " }";
<< ", GetSplitNodeDirection()="
<< aTransaction.GetSplitNodeDirection() << " }";
return aStream; return aStream;
} }
@ -86,16 +83,6 @@ NS_IMPL_RELEASE_INHERITED(SplitNodeTransaction, EditTransactionBase)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SplitNodeTransaction) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SplitNodeTransaction)
NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase) NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
SplitNodeDirection SplitNodeTransaction::GetSplitNodeDirection() const {
return MOZ_LIKELY(mHTMLEditor) ? mHTMLEditor->GetSplitNodeDirection()
: SplitNodeDirection::LeftNodeIsNewOne;
}
JoinNodesDirection SplitNodeTransaction::GetJoinNodesDirection() const {
return MOZ_LIKELY(mHTMLEditor) ? mHTMLEditor->GetJoinNodesDirection()
: JoinNodesDirection::LeftNodeIntoRightNode;
}
NS_IMETHODIMP SplitNodeTransaction::DoTransaction() { NS_IMETHODIMP SplitNodeTransaction::DoTransaction() {
MOZ_LOG(GetLogModule(), LogLevel::Info, MOZ_LOG(GetLogModule(), LogLevel::Info,
("%p SplitNodeTransaction::%s this=%s", this, __FUNCTION__, ("%p SplitNodeTransaction::%s this=%s", this, __FUNCTION__,
@ -183,20 +170,12 @@ NS_IMETHODIMP SplitNodeTransaction::UndoTransaction() {
const OwningNonNull<HTMLEditor> htmlEditor = *mHTMLEditor; const OwningNonNull<HTMLEditor> htmlEditor = *mHTMLEditor;
const OwningNonNull<nsIContent> keepingContent = *mSplitContent; const OwningNonNull<nsIContent> keepingContent = *mSplitContent;
const OwningNonNull<nsIContent> removingContent = *mNewContent; const OwningNonNull<nsIContent> removingContent = *mNewContent;
nsresult rv;
EditorDOMPoint joinedPoint; EditorDOMPoint joinedPoint;
{ // Unfortunately, we cannot track joining point if moving right node content
// Unfortunately, we cannot track joining point if moving right node content // into left node since it cannot track changes from web apps and HTMLEditor
// into left node since it cannot track changes from web apps and HTMLEditor // never removes the content of the left node. So it should be true that
// never removes the content of the left node. So it should be true that // we don't need to track the point in this case.
// we don't need to track the point in the direction. nsresult rv = htmlEditor->DoJoinNodes(keepingContent, removingContent);
Maybe<AutoTrackDOMPoint> trackJoinedPoint;
if (GetJoinNodesDirection() == JoinNodesDirection::LeftNodeIntoRightNode) {
joinedPoint.Set(keepingContent, 0u);
trackJoinedPoint.emplace(htmlEditor->RangeUpdaterRef(), &joinedPoint);
}
rv = htmlEditor->DoJoinNodes(keepingContent, removingContent);
}
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Adjust split offset for redo here // Adjust split offset for redo here
if (joinedPoint.IsSet()) { if (joinedPoint.IsSet()) {

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

@ -53,11 +53,6 @@ class SplitNodeTransaction final : public EditTransactionBase {
MOZ_CAN_RUN_SCRIPT NS_IMETHOD RedoTransaction() override; MOZ_CAN_RUN_SCRIPT NS_IMETHOD RedoTransaction() override;
// Note that we don't support join/split node direction switching per
// transaction.
[[nodiscard]] SplitNodeDirection GetSplitNodeDirection() const;
[[nodiscard]] JoinNodesDirection GetJoinNodesDirection() const;
nsIContent* GetSplitContent() const { return mSplitContent; } nsIContent* GetSplitContent() const { return mSplitContent; }
nsIContent* GetNewContent() const { return mNewContent; } nsIContent* GetNewContent() const { return mNewContent; }
nsINode* GetParentNode() const { return mParentNode; } nsINode* GetParentNode() const { return mParentNode; }

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

@ -50,16 +50,10 @@ interface nsIEditActionListener : nsISupports
* right node. Otherwise, it points start of inserted * right node. Otherwise, it points start of inserted
* right node content in the left node. * right node content in the left node.
* @param aRemovedNode The removed node. * @param aRemovedNode The removed node.
* @param aLeftNodeWasRemoved
* true if left node is removed and its contents were
* moved into start of the right node.
* false if right node is removed and its contents were
* moved into end of the left node.
*/ */
[noscript] [noscript]
void DidJoinContents([const] in EditorRawDOMPointRef aJoinedPoint, void DidJoinContents([const] in EditorRawDOMPointRef aJoinedPoint,
[const] in Node aRemovedNode, [const] in Node aRemovedNode);
in bool aLeftNodeWasRemoved);
/** /**
* Called after the editor inserts text. * Called after the editor inserts text.

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

@ -10,7 +10,6 @@
#include "FilteredContentIterator.h" // for FilteredContentIterator #include "FilteredContentIterator.h" // for FilteredContentIterator
#include "HTMLEditHelpers.h" // for BlockInlineCheck #include "HTMLEditHelpers.h" // for BlockInlineCheck
#include "HTMLEditUtils.h" // for HTMLEditUtils #include "HTMLEditUtils.h" // for HTMLEditUtils
#include "JoinSplitNodeDirection.h" // for JoinNodesDirection
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/IntegerRange.h" // for IntegerRange #include "mozilla/IntegerRange.h" // for IntegerRange
@ -1338,8 +1337,7 @@ void TextServicesDocument::DidDeleteContent(const nsIContent& aChildContent) {
} }
void TextServicesDocument::DidJoinContents( void TextServicesDocument::DidJoinContents(
const EditorRawDOMPoint& aJoinedPoint, const nsIContent& aRemovedContent, const EditorRawDOMPoint& aJoinedPoint, const nsIContent& aRemovedContent) {
JoinNodesDirection aJoinNodesDirection) {
// Make sure that both nodes are text nodes -- otherwise we don't care. // Make sure that both nodes are text nodes -- otherwise we don't care.
if (!aJoinedPoint.IsInTextNode() || !aRemovedContent.IsText()) { if (!aJoinedPoint.IsInTextNode() || !aRemovedContent.IsText()) {
return; return;
@ -1367,30 +1365,19 @@ void TextServicesDocument::DidJoinContents(
const size_t removedIndex = *maybeRemovedIndex; const size_t removedIndex = *maybeRemovedIndex;
const size_t joinedIndex = *maybeJoinedIndex; const size_t joinedIndex = *maybeJoinedIndex;
if (aJoinNodesDirection == JoinNodesDirection::LeftNodeIntoRightNode) { if (MOZ_UNLIKELY(joinedIndex > removedIndex)) {
if (MOZ_UNLIKELY(removedIndex > joinedIndex)) { NS_ASSERTION(joinedIndex < removedIndex, "Indexes out of order.");
NS_ASSERTION(removedIndex < joinedIndex, "Indexes out of order."); return;
return;
}
NS_ASSERTION(mOffsetTable[joinedIndex]->mOffsetInTextNode == 0,
"Unexpected offset value for joinedIndex.");
} else {
if (MOZ_UNLIKELY(joinedIndex > removedIndex)) {
NS_ASSERTION(joinedIndex < removedIndex, "Indexes out of order.");
return;
}
NS_ASSERTION(mOffsetTable[removedIndex]->mOffsetInTextNode == 0,
"Unexpected offset value for rightIndex.");
} }
NS_ASSERTION(mOffsetTable[removedIndex]->mOffsetInTextNode == 0,
"Unexpected offset value for rightIndex.");
// Run through the table and change all entries referring to // Run through the table and change all entries referring to
// the removed node so that they now refer to the joined node, // the removed node so that they now refer to the joined node,
// and adjust offsets if necessary. // and adjust offsets if necessary.
const uint32_t movedTextDataLength = const uint32_t movedTextDataLength =
aJoinNodesDirection == JoinNodesDirection::LeftNodeIntoRightNode aJoinedPoint.ContainerAs<Text>()->TextDataLength() -
? aJoinedPoint.Offset() aJoinedPoint.Offset();
: aJoinedPoint.ContainerAs<Text>()->TextDataLength() -
aJoinedPoint.Offset();
for (uint32_t i = removedIndex; i < mOffsetTable.Length(); i++) { for (uint32_t i = removedIndex; i < mOffsetTable.Length(); i++) {
const UniquePtr<OffsetEntry>& entry = mOffsetTable[i]; const UniquePtr<OffsetEntry>& entry = mOffsetTable[i];
LockOffsetEntryArrayLengthInDebugBuild(observer, mOffsetTable); LockOffsetEntryArrayLengthInDebugBuild(observer, mOffsetTable);
@ -1399,26 +1386,9 @@ void TextServicesDocument::DidJoinContents(
} }
if (entry->mIsValid) { if (entry->mIsValid) {
entry->mTextNode = aJoinedPoint.ContainerAs<Text>(); entry->mTextNode = aJoinedPoint.ContainerAs<Text>();
if (aJoinNodesDirection == JoinNodesDirection::RightNodeIntoLeftNode) { // The text was moved from aRemovedContent to end of the container of
// The text was moved from aRemovedContent to end of the container of // aJoinedPoint.
// aJoinedPoint. entry->mOffsetInTextNode += movedTextDataLength;
entry->mOffsetInTextNode += movedTextDataLength;
}
}
}
if (aJoinNodesDirection == JoinNodesDirection::LeftNodeIntoRightNode) {
// The text was moved from aRemovedContent to start of the container of
// aJoinedPoint.
for (uint32_t i = joinedIndex; i < mOffsetTable.Length(); i++) {
const UniquePtr<OffsetEntry>& entry = mOffsetTable[i];
LockOffsetEntryArrayLengthInDebugBuild(observer, mOffsetTable);
if (entry->mTextNode != aJoinedPoint.ContainerAs<Text>()) {
break;
}
if (entry->mIsValid) {
entry->mOffsetInTextNode += movedTextDataLength;
}
} }
} }
@ -2784,16 +2754,12 @@ TextServicesDocument::DidDeleteNode(nsINode* aChild, nsresult aResult) {
} }
NS_IMETHODIMP TextServicesDocument::DidJoinContents( NS_IMETHODIMP TextServicesDocument::DidJoinContents(
const EditorRawDOMPoint& aJoinedPoint, const nsINode* aRemovedNode, const EditorRawDOMPoint& aJoinedPoint, const nsINode* aRemovedNode) {
bool aLeftNodeWasRemoved) {
if (MOZ_UNLIKELY(NS_WARN_IF(!aJoinedPoint.IsSetAndValid()) || if (MOZ_UNLIKELY(NS_WARN_IF(!aJoinedPoint.IsSetAndValid()) ||
NS_WARN_IF(!aRemovedNode->IsContent()))) { NS_WARN_IF(!aRemovedNode->IsContent()))) {
return NS_OK; return NS_OK;
} }
DidJoinContents(aJoinedPoint, *aRemovedNode->AsContent(), DidJoinContents(aJoinedPoint, *aRemovedNode->AsContent());
aLeftNodeWasRemoved
? JoinNodesDirection::LeftNodeIntoRightNode
: JoinNodesDirection::RightNodeIntoLeftNode);
return NS_OK; return NS_OK;
} }

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

@ -27,7 +27,6 @@ namespace mozilla {
class EditorBase; class EditorBase;
class FilteredContentIterator; class FilteredContentIterator;
class OffsetEntry; class OffsetEntry;
enum class JoinNodesDirection; // Declared in HTMLEditHelpers.h
namespace dom { namespace dom {
class AbstractRange; class AbstractRange;
@ -374,8 +373,7 @@ class TextServicesDocument final : public nsIEditActionListener {
*/ */
void DidDeleteContent(const nsIContent& aChildContent); void DidDeleteContent(const nsIContent& aChildContent);
void DidJoinContents(const EditorRawDOMPoint& aJoinedPoint, void DidJoinContents(const EditorRawDOMPoint& aJoinedPoint,
const nsIContent& aRemovedContent, const nsIContent& aRemovedContent);
JoinNodesDirection aJoinNodesDirection);
private: private:
// TODO: We should get rid of this method since `aAbstractRange` has // TODO: We should get rid of this method since `aAbstractRange` has