From 58f9c64190482dccdea7db340836f6a78791a031 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 18 Sep 2019 12:37:14 +0000 Subject: [PATCH] Bug 1581034 - part 2: Get rid of `TextEditUtils::IsBreak()` and `TextEditUtils` itself r=m_kato Differential Revision: https://phabricator.services.mozilla.com/D45811 --HG-- extra : moz-landing-system : lando --- editor/libeditor/EditorBase.cpp | 1 - editor/libeditor/HTMLAbsPositionEditor.cpp | 1 - editor/libeditor/HTMLEditSubActionHandler.cpp | 23 ++++++----- editor/libeditor/HTMLEditUtils.cpp | 1 - editor/libeditor/HTMLEditor.cpp | 9 ++--- editor/libeditor/HTMLEditorDataTransfer.cpp | 4 +- editor/libeditor/HTMLStyleEditor.cpp | 9 ++--- editor/libeditor/TextEditSubActionHandler.cpp | 1 - editor/libeditor/TextEditUtils.cpp | 38 ------------------- editor/libeditor/TextEditUtils.h | 24 ------------ editor/libeditor/TextEditor.cpp | 1 - editor/libeditor/WSRunObject.cpp | 6 +-- editor/libeditor/moz.build | 1 - 13 files changed, 23 insertions(+), 96 deletions(-) delete mode 100644 editor/libeditor/TextEditUtils.cpp delete mode 100644 editor/libeditor/TextEditUtils.h diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 650a3eda8fb8..4fe91084a723 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -24,7 +24,6 @@ #include "JoinNodeTransaction.h" // for JoinNodeTransaction #include "PlaceholderTransaction.h" // for PlaceholderTransaction #include "SplitNodeTransaction.h" // for SplitNodeTransaction -#include "TextEditUtils.h" // for TextEditUtils #include "mozilla/CheckedInt.h" // for CheckedInt #include "mozilla/ComputedStyle.h" // for ComputedStyle #include "mozilla/CSSEditUtils.h" // for CSSEditUtils diff --git a/editor/libeditor/HTMLAbsPositionEditor.cpp b/editor/libeditor/HTMLAbsPositionEditor.cpp index 71ba59f9f4a3..1146311c99a1 100644 --- a/editor/libeditor/HTMLAbsPositionEditor.cpp +++ b/editor/libeditor/HTMLAbsPositionEditor.cpp @@ -8,7 +8,6 @@ #include "HTMLEditorEventListener.h" #include "HTMLEditUtils.h" -#include "TextEditUtils.h" #include "mozilla/EditAction.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" diff --git a/editor/libeditor/HTMLEditSubActionHandler.cpp b/editor/libeditor/HTMLEditSubActionHandler.cpp index e27938bf779f..3d658042227f 100644 --- a/editor/libeditor/HTMLEditSubActionHandler.cpp +++ b/editor/libeditor/HTMLEditSubActionHandler.cpp @@ -7,7 +7,6 @@ #include "HTMLEditor.h" #include "HTMLEditUtils.h" -#include "TextEditUtils.h" #include "WSRunObject.h" #include "mozilla/Assertions.h" #include "mozilla/ContentIterator.h" @@ -4253,7 +4252,7 @@ EditActionResult HTMLEditor::ChangeSelectedHardLinesToList( bool bOnlyBreaks = true; for (auto& curNode : arrayOfNodes) { // if curNode is not a Break or empty inline, we're done - if (!TextEditUtils::IsBreak(curNode) && !IsEmptyInineNode(curNode)) { + if (!curNode->IsHTMLElement(nsGkAtoms::br) && !IsEmptyInineNode(curNode)) { bOnlyBreaks = false; break; } @@ -6427,7 +6426,7 @@ nsresult HTMLEditor::AlignContentsAtSelection(const nsAString& aAlignType) { return rv; } - if (TextEditUtils::IsBreak(node)) { + if (node->IsHTMLElement(nsGkAtoms::br)) { // The special case createEmptyDivElement code (below) that consumes // `
` elements can cause tables to split if the start node of the // selection is not in a table cell or caption, for example parent is a @@ -6499,7 +6498,8 @@ EditActionResult HTMLEditor::AlignContentsAtSelectionWithEmptyDivElement( // creating extra lines, if possible. if (nsCOMPtr maybeBRContent = GetNextEditableHTMLNodeInBlock(splitNodeResult.SplitPoint())) { - if (TextEditUtils::IsBreak(maybeBRContent) && pointToInsertDiv.GetChild()) { + if (maybeBRContent->IsHTMLElement(nsGkAtoms::br) && + pointToInsertDiv.GetChild()) { // Making use of html structure... if next node after where we are // putting our div is not a block, then the br we found is in same block // we are, so it's safe to consume it. @@ -8449,7 +8449,7 @@ EditActionResult HTMLEditor::HandleInsertParagraphInParagraph( splitAfterNewBR = true; } } - if (!pointToInsertBR.IsSet() && TextEditUtils::IsBreak(nearNode)) { + if (!pointToInsertBR.IsSet() && nearNode->IsHTMLElement(nsGkAtoms::br)) { brContent = nearNode; } } @@ -9812,7 +9812,7 @@ nsresult HTMLEditor::AdjustCaretPositionAndEnsurePaddingBRElement( if (blockElementAtCaret && blockElementAtCaret == blockElementParentAtPreviousEditableContent && previousEditableContent && - TextEditUtils::IsBreak(previousEditableContent)) { + previousEditableContent->IsHTMLElement(nsGkAtoms::br)) { // If it's an invisible `
` element, we need to insert a padding // `
` element for making empty line have one-line height. if (!IsVisibleBRElement(previousEditableContent)) { @@ -9862,7 +9862,7 @@ nsresult HTMLEditor::AdjustCaretPositionAndEnsurePaddingBRElement( // or `
`, current caret position is fine. if (nsIContent* previousEditableContentInBlock = GetPreviousEditableHTMLNodeInBlock(point)) { - if (TextEditUtils::IsBreak(previousEditableContentInBlock) || + if (previousEditableContentInBlock->IsHTMLElement(nsGkAtoms::br) || EditorBase::IsTextNode(previousEditableContentInBlock) || HTMLEditUtils::IsImage(previousEditableContentInBlock) || previousEditableContentInBlock->IsHTMLElement(nsGkAtoms::hr)) { @@ -9873,10 +9873,9 @@ nsresult HTMLEditor::AdjustCaretPositionAndEnsurePaddingBRElement( // `
`, current caret position is fine. if (nsIContent* nextEditableContentInBlock = GetNextEditableHTMLNodeInBlock(point)) { - if (TextEditUtils::IsBreak(nextEditableContentInBlock) || - EditorBase::IsTextNode(nextEditableContentInBlock) || - nextEditableContentInBlock->IsAnyOfHTMLElements(nsGkAtoms::img, - nsGkAtoms::hr)) { + if (EditorBase::IsTextNode(nextEditableContentInBlock) || + nextEditableContentInBlock->IsAnyOfHTMLElements( + nsGkAtoms::br, nsGkAtoms::img, nsGkAtoms::hr)) { return NS_OK; } } @@ -9932,7 +9931,7 @@ nsIContent* HTMLEditor::FindNearEditableContent( // XXX This comment sounds odd. editableContent may have already crossed // breaks and/or images if they are non-editable. while (editableContent && !EditorBase::IsTextNode(editableContent) && - !TextEditUtils::IsBreak(editableContent) && + !editableContent->IsHTMLElement(nsGkAtoms::br) && !HTMLEditUtils::IsImage(editableContent)) { if (aDirection == nsIEditor::ePrevious) { editableContent = GetPreviousEditableHTMLNode(*editableContent); diff --git a/editor/libeditor/HTMLEditUtils.cpp b/editor/libeditor/HTMLEditUtils.cpp index 7535920eff7b..64ef58361746 100644 --- a/editor/libeditor/HTMLEditUtils.cpp +++ b/editor/libeditor/HTMLEditUtils.cpp @@ -5,7 +5,6 @@ #include "HTMLEditUtils.h" -#include "TextEditUtils.h" // for TextEditUtils #include "mozilla/ArrayUtils.h" // for ArrayLength #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc. #include "mozilla/EditAction.h" // for EditAction diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 0b16e80481f8..a9a6a922f86a 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -24,7 +24,6 @@ #include "HTMLEditorEventListener.h" #include "HTMLEditUtils.h" -#include "TextEditUtils.h" #include "TypeInState.h" #include "nsHTMLDocument.h" @@ -883,7 +882,7 @@ void HTMLEditor::IsPrevCharInNodeWhitespace(nsIContent* aContent, bool HTMLEditor::IsVisibleBRElement(nsINode* aNode) { MOZ_ASSERT(aNode); - if (!TextEditUtils::IsBreak(aNode)) { + if (!aNode->IsHTMLElement(nsGkAtoms::br)) { return false; } // Check if there is another element or text node in block after current @@ -893,7 +892,7 @@ bool HTMLEditor::IsVisibleBRElement(nsINode* aNode) { // E.g., foo
// However, we need to ignore invisible data nodes like comment node. nsCOMPtr nextNode = GetNextHTMLElementOrTextInBlock(*aNode); - if (nextNode && TextEditUtils::IsBreak(nextNode)) { + if (nextNode && nextNode->IsHTMLElement(nsGkAtoms::br)) { return true; } @@ -916,7 +915,7 @@ bool HTMLEditor::IsVisibleBRElement(nsINode* aNode) { // E.g.,