Skip to content

Commit

Permalink
Bug 1795061 - Stop exposing JoinSplitNodeDirection.h r=m_kato
Browse files Browse the repository at this point in the history
Including it in `HTMLEditor.h` causes creating static constructors for
the modules which include `HTMLEditor.h`.  And the public methods are used
only in the `libeditor`.  Therefore, we can make `HTMLEditor.h` stop including
it and stop exposing `JoinSplitNodeDirection.h`.

Differential Revision: https://phabricator.services.mozilla.com/D159363
  • Loading branch information
masayuki-nakano committed Oct 19, 2022
1 parent 599b985 commit a2e038d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 25 deletions.
5 changes: 2 additions & 3 deletions editor/libeditor/EditorForwards.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ enum class CollectChildrenOption; // HTMLEditUtils.h
enum class EditAction; // mozilla/EditAction.h
enum class EditorCommandParamType : uint16_t; // mozilla/EditorCommands.h
enum class EditSubAction : int32_t; // mozilla/EditAction.h
enum class JoinNodesDirection; // JoinSplitNodeDirection.h
enum class ParagraphSeparator; // mozilla/HTMLEditor.h
enum class SpecifiedStyle : uint8_t; // mozilla/PendingStyles.h
enum class SplitNodeDirection; // JoinSplitNodeDirection.h
enum class SuggestCaret; // EditorUtils.h

enum class JoinNodesDirection; // HTMLEditHelper.h
enum class SplitNodeDirection; // HTMLEditHelper.h

/******************************************************************************
* enum sets
******************************************************************************/
Expand Down
27 changes: 10 additions & 17 deletions editor/libeditor/HTMLEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "mozilla/EditorBase.h"
#include "mozilla/EditorForwards.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/JoinSplitNodeDirection.h"
#include "mozilla/ManualNAC.h"
#include "mozilla/Result.h"
#include "mozilla/dom/BlobImpl.h"
Expand Down Expand Up @@ -606,20 +605,6 @@ class HTMLEditor final : public EditorBase,
}
}

/**
* Get split/join node(s) direction for **this** instance.
*/
[[nodiscard]] SplitNodeDirection GetSplitNodeDirection() const {
return MOZ_LIKELY(mUseGeckoTraditionalJoinSplitBehavior)
? SplitNodeDirection::LeftNodeIsNewOne
: SplitNodeDirection::RightNodeIsNewOne;
}
[[nodiscard]] JoinNodesDirection GetJoinNodesDirection() const {
return MOZ_LIKELY(mUseGeckoTraditionalJoinSplitBehavior)
? JoinNodesDirection::LeftNodeIntoRightNode
: JoinNodesDirection::RightNodeIntoLeftNode;
}

/**
* Modifies the table containing the selection according to the
* activation of an inline table editing UI element
Expand Down Expand Up @@ -2657,6 +2642,12 @@ class HTMLEditor final : public EditorBase,
MOZ_CAN_RUN_SCRIPT nsresult OnDocumentModified();

protected: // Called by helper classes.
/**
* Get split/join node(s) direction for **this** instance.
*/
[[nodiscard]] inline SplitNodeDirection GetSplitNodeDirection() const;
[[nodiscard]] inline JoinNodesDirection GetJoinNodesDirection() const;

MOZ_CAN_RUN_SCRIPT void OnStartToHandleTopLevelEditSubAction(
EditSubAction aTopLevelEditSubAction,
nsIEditor::EDirection aDirectionOfTopLevelEditSubAction,
Expand Down Expand Up @@ -4555,7 +4546,8 @@ class HTMLEditor final : public EditorBase,
// RemoveEmptyInclusiveAncestorInlineElements,
// mComposerUpdater, mHasBeforeInputBeenCanceled
friend class JoinNodesTransaction; // DidJoinNodesTransaction, DoJoinNodes,
// DoSplitNode, RangeUpdaterRef
// DoSplitNode, GetJoinNodesDirection,
// RangeUpdaterRef
friend class ListElementSelectionState; // CollectEditTargetNodes,
// CollectNonEditableNodes
friend class ListItemElementSelectionState; // CollectEditTargetNodes,
Expand All @@ -4569,7 +4561,8 @@ class HTMLEditor final : public EditorBase,
// CollectNonEditableNodes,
// CollectTableChildren
friend class SlurpBlobEventListener; // BlobReader
friend class SplitNodeTransaction; // DoJoinNodes, DoSplitNode
friend class SplitNodeTransaction; // DoJoinNodes, DoSplitNode,
// GetSplitNodeDirection
friend class TransactionManager; // DidDoTransaction, DidRedoTransaction,
// DidUndoTransaction
friend class
Expand Down
16 changes: 15 additions & 1 deletion editor/libeditor/HTMLEditorInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

#include "EditorDOMPoint.h"
#include "HTMLEditHelpers.h"
#include "SelectionState.h" // for RangeItem
#include "JoinSplitNodeDirection.h" // for JoinNodesDirection and SplitNodeDirection
#include "SelectionState.h" // for RangeItem

#include "ErrorList.h" // for nsresult

#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Debug.h"
#include "mozilla/Likely.h"
#include "mozilla/RefPtr.h"

#include "mozilla/dom/Element.h"
Expand All @@ -30,6 +32,18 @@ namespace mozilla {

using namespace dom;

SplitNodeDirection HTMLEditor::GetSplitNodeDirection() const {
return MOZ_LIKELY(mUseGeckoTraditionalJoinSplitBehavior)
? SplitNodeDirection::LeftNodeIsNewOne
: SplitNodeDirection::RightNodeIsNewOne;
}

JoinNodesDirection HTMLEditor::GetJoinNodesDirection() const {
return MOZ_LIKELY(mUseGeckoTraditionalJoinSplitBehavior)
? JoinNodesDirection::LeftNodeIntoRightNode
: JoinNodesDirection::RightNodeIntoLeftNode;
}

Result<CreateElementResult, nsresult>
HTMLEditor::ReplaceContainerAndCloneAttributesWithTransaction(
Element& aOldContainer, const nsAtom& aTagName) {
Expand Down
1 change: 1 addition & 0 deletions editor/libeditor/JoinNodesTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "HTMLEditHelpers.h" // for SplitNodeResult
#include "JoinSplitNodeDirection.h" // JoinNodesDirection
#include "HTMLEditor.h" // for HTMLEditor
#include "HTMLEditorInlines.h"
#include "HTMLEditUtils.h"

#include "mozilla/Logging.h"
Expand Down
6 changes: 3 additions & 3 deletions editor/libeditor/JoinSplitNodeDirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_JoinSplitNodeDirection_h
#define mozilla_JoinSplitNodeDirection_h
#ifndef JoinSplitNodeDirection_h
#define JoinSplitNodeDirection_h

#include <iostream>

Expand Down Expand Up @@ -48,4 +48,4 @@ static inline std::ostream& operator<<(std::ostream& aStream,

} // namespace mozilla

#endif // mozilla_JoinSplitNodeDirection_h
#endif // JoinSplitNodeDirection_h
1 change: 1 addition & 0 deletions editor/libeditor/SplitNodeTransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "EditorDOMPoint.h" // for EditorRawDOMPoint
#include "HTMLEditHelpers.h" // for SplitNodeResult
#include "HTMLEditor.h" // for HTMLEditor
#include "HTMLEditorInlines.h"
#include "HTMLEditUtils.h"
#include "JoinSplitNodeDirection.h" // for SplitNodeDirection
#include "SelectionState.h" // for AutoTrackDOMPoint and RangeUpdater
Expand Down
1 change: 0 additions & 1 deletion editor/libeditor/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ EXPORTS.mozilla += [
"EditTransactionBase.h",
"HTMLEditor.h",
"HTMLEditorController.h",
"JoinSplitNodeDirection.h",
"ManualNAC.h",
"PendingStyles.h",
"SelectionState.h",
Expand Down

0 comments on commit a2e038d

Please sign in to comment.