Bug 1470861: Mark some methods const now that they don't mutate nsFind itself. r?mats draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 25 Jun 2018 13:20:43 +0200
changeset 810143 87131e3374b08808aad85d7dfe6b88d1846e2607
parent 810142 8137a3f6cb3ab284567e1bc095d5481e33768307
push id113905
push userbmo:emilio@crisal.io
push dateMon, 25 Jun 2018 12:31:46 +0000
reviewersmats
bugs1470861
milestone62.0a1
Bug 1470861: Mark some methods const now that they don't mutate nsFind itself. r?mats MozReview-Commit-ID: BBZlZ5FrP5K
toolkit/components/find/nsFind.cpp
toolkit/components/find/nsFind.h
--- a/toolkit/components/find/nsFind.cpp
+++ b/toolkit/components/find/nsFind.cpp
@@ -642,17 +642,17 @@ GetBlockParent(nsINode* aNode)
   return nullptr;
 }
 
 nsresult
 nsFind::InitIterator(State& aState,
                      nsINode* aStartNode,
                      int32_t aStartOffset,
                      nsINode* aEndNode,
-                     int32_t aEndOffset)
+                     int32_t aEndOffset) const
 {
   if (!aState.mIterator) {
     aState.mIterator = new nsFindContentIterator(mFindBackward);
   }
 
   NS_ENSURE_ARG_POINTER(aStartNode);
   NS_ENSURE_ARG_POINTER(aEndNode);
 
@@ -742,17 +742,17 @@ nsFind::SetEntireWord(bool aEntireWord)
 // union of a one-byte string or a two-byte string. Single and double strings
 // are intermixed in the dom. We don't have string classes which can deal with
 // intermixed strings, so all the handling is done explicitly here.
 
 nsresult
 nsFind::NextNode(State& aState,
                  nsRange* aSearchRange,
                  nsRange* aStartPoint,
-                 nsRange* aEndPoint)
+                 nsRange* aEndPoint) const
 {
   nsresult rv;
 
   nsCOMPtr<nsIContent> content;
 
   if (!aState.mIterator) {
     // If we are continuing, that means we have a match in progress. In that
     // case, we want to continue from the end point (where we are now) to the
@@ -863,17 +863,17 @@ nsFind::NextNode(State& aState,
   DumpNode(aState.mIterNode);
   return NS_OK;
 }
 
 char16_t
 nsFind::PeekNextChar(State& aState,
                      nsRange* aSearchRange,
                      nsRange* aStartPoint,
-                     nsRange* aEndPoint)
+                     nsRange* aEndPoint) const
 {
   // We need to restore the necessary state before this function returns.
   StateRestorer restorer(aState);
 
   const nsTextFragment *frag;
   int32_t fragLen;
 
   // Loop through non-block nodes until we find one that's not empty.
--- a/toolkit/components/find/nsFind.h
+++ b/toolkit/components/find/nsFind.h
@@ -47,27 +47,27 @@ protected:
 
   struct State;
   class StateRestorer;
 
   // Move in the right direction for our search:
   nsresult NextNode(State&,
                     nsRange* aSearchRange,
                     nsRange* aStartPoint,
-                    nsRange* aEndPoint);
+                    nsRange* aEndPoint) const;
 
   // Get the first character from the next node (last if mFindBackward).
   //
   // This will mutate the state, but then restore it afterwards.
   char16_t PeekNextChar(State&,
                         nsRange* aSearchRange,
                         nsRange* aStartPoint,
-                        nsRange* aEndPoint);
+                        nsRange* aEndPoint) const;
 
   // The iterator we use to move through the document:
   nsresult InitIterator(State&,
                         nsINode* aStartNode,
                         int32_t aStartOffset,
                         nsINode* aEndNode,
-                        int32_t aEndOffset);
+                        int32_t aEndOffset) const;
 };
 
 #endif // nsFind_h__