Bug 1417376 Part 1 - Change nsPoint parameter to pass by value for DoAutoScroll(). draft
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 16 Nov 2017 10:32:22 +0800
changeset 700417 6c00dc91cec25ea8351ba94845e110b540f69b79
parent 700338 dd08f8b19cc32da161811abb2f7093e0f5392e69
child 700418 15d9d67190144ed328d1244110639ea1c3b321fe
push id89813
push userbmo:tlin@mozilla.com
push dateMon, 20 Nov 2017 04:09:24 +0000
bugs1417376
milestone59.0a1
Bug 1417376 Part 1 - Change nsPoint parameter to pass by value for DoAutoScroll(). This private method DoAutoScroll() modifies aPoint inside of it, and none of other callers (StartAutoScrollTimer() and nsAutoScrollTimer::Notify()) read aPoint afterwards, so we make aPoint pass by value rather than pass by non-const-reference. This is necessary for later parts. MozReview-Commit-ID: 9PtxFXIka7X
dom/base/Selection.cpp
dom/base/Selection.h
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2210,17 +2210,17 @@ Selection::StopAutoScrollTimer()
 {
   if (mAutoScrollTimer) {
     return mAutoScrollTimer->Stop();
   }
   return NS_OK;
 }
 
 nsresult
-Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint& aPoint)
+Selection::DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint)
 {
   NS_PRECONDITION(aFrame, "Need a frame");
 
   if (mAutoScrollTimer) {
     (void)mAutoScrollTimer->Stop();
   }
 
   nsPresContext* presContext = aFrame->PresContext();
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -329,17 +329,17 @@ public:
    */
   nsresult SetTextRangeStyle(nsRange* aRange,
                              const TextRangeStyle& aTextRangeStyle);
 
 private:
   friend class ::nsAutoScrollTimer;
 
   // Note: DoAutoScroll might destroy arbitrary frames etc.
-  nsresult DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint);
+  nsresult DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint);
 
   // We are not allowed to be in nodes whose root is not our document
   bool HasSameRoot(nsINode& aNode);
 
   // XXX Please don't add additional uses of this method, it's only for
   // XXX supporting broken code (bug 1245883) in the following classes:
   friend class ::nsCopySupport;
   friend class ::nsHTMLCopyEncoder;