Bug 1640276 - Part 2: Mark nsINode as const in Find*Node() r=masayuki
authorKagami Sascha Rosylight <saschanaz@outlook.com>
Sat, 23 May 2020 12:38:50 +0000
changeset 531777 ac943e455cf43a61be56ef03d3ad61bc3ea74ac8
parent 531776 ea0f8a5cacdce1f500f00df62ade438a55a52e3c
child 531778 77aab1a07cfc6a3cd566bde4a3d1020a10a57d42
push id37443
push usercbrindusan@mozilla.com
push dateSat, 23 May 2020 21:42:57 +0000
treeherdermozilla-central@9a2f741cef6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1640276
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1640276 - Part 2: Mark nsINode as const in Find*Node() r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D76563
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -2917,24 +2917,25 @@ nsIContent* EditorBase::GetNextNodeInter
     // don't cross out of parent block
     return nullptr;
   }
 
   return GetNextNodeInternal(*point.GetContainer(), aFindEditableNode,
                              aFindAnyDataNode, aNoBlockCrossing);
 }
 
-nsIContent* EditorBase::FindNextLeafNode(nsINode* aCurrentNode, bool aGoForward,
+nsIContent* EditorBase::FindNextLeafNode(const nsINode* aCurrentNode,
+                                         bool aGoForward,
                                          bool bNoBlockCrossing) const {
   // called only by GetPriorNode so we don't need to check params.
   MOZ_ASSERT(
       IsDescendantOfEditorRoot(aCurrentNode) && !IsEditorRoot(aCurrentNode),
       "Bogus arguments");
 
-  nsINode* cur = aCurrentNode;
+  const nsINode* cur = aCurrentNode;
   for (;;) {
     // if aCurrentNode has a sibling in the right direction, return
     // that sibling's closest child (or itself if it has no children)
     nsIContent* sibling =
         aGoForward ? cur->GetNextSibling() : cur->GetPreviousSibling();
     if (sibling) {
       if (bNoBlockCrossing && HTMLEditUtils::IsBlockElement(*sibling)) {
         // don't look inside prevsib, since it is a block
@@ -2967,17 +2968,17 @@ nsIContent* EditorBase::FindNextLeafNode
 
     cur = parent;
   }
 
   MOZ_ASSERT_UNREACHABLE("What part of for(;;) do you not understand?");
   return nullptr;
 }
 
-nsIContent* EditorBase::FindNode(nsINode* aCurrentNode, bool aGoForward,
+nsIContent* EditorBase::FindNode(const nsINode* aCurrentNode, bool aGoForward,
                                  bool aEditableNode, bool aFindAnyDataNode,
                                  bool bNoBlockCrossing) const {
   if (IsEditorRoot(aCurrentNode)) {
     // Don't allow traversal above the root node! This helps
     // prevent us from accidentally editing browser content
     // when the editor is in a text widget.
 
     return nullptr;
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -2021,19 +2021,19 @@ class EditorBase : public nsIEditor,
    * the editor's sync/async settings for reflowing, painting, and scrolling
    * match.
    */
   [[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult ScrollSelectionFocusIntoView();
 
   /**
    * Helper for GetPreviousNodeInternal() and GetNextNodeInternal().
    */
-  nsIContent* FindNextLeafNode(nsINode* aCurrentNode, bool aGoForward,
+  nsIContent* FindNextLeafNode(const nsINode* aCurrentNode, bool aGoForward,
                                bool bNoBlockCrossing) const;
-  nsIContent* FindNode(nsINode* aCurrentNode, bool aGoForward,
+  nsIContent* FindNode(const nsINode* aCurrentNode, bool aGoForward,
                        bool aEditableNode, bool aFindAnyDataNode,
                        bool bNoBlockCrossing) const;
 
   /**
    * Get the node immediately previous node of aNode.
    * @param atNode               The node from which we start the search.
    * @param aFindEditableNode    If true, only return an editable node.
    * @param aFindAnyDataNode     If true, may return invisible data node