Bug 1387143 part 9. Remove nsISelectionPrivate::Get/SetAncestorLimiter. r=mats
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 May 2018 13:52:37 -0400
changeset 417437 26a0de789a136f820e45d1eaaf0521b4fd74efbf
parent 417436 89f2f9869b1a720152890ae2e6f759f58e6b6ac0
child 417438 560215a5ceda5097e64fed8b9b544ce700e1807f
push id33967
push useraciure@mozilla.com
push dateTue, 08 May 2018 22:59:40 +0000
treeherdermozilla-central@0cd106a2eb78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1387143
milestone62.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 1387143 part 9. Remove nsISelectionPrivate::Get/SetAncestorLimiter. r=mats
dom/base/Selection.cpp
dom/base/Selection.h
dom/base/nsISelectionPrivate.idl
dom/events/ContentEventHandler.cpp
editor/libeditor/HTMLEditor.cpp
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -2049,34 +2049,32 @@ Selection::GetCachedFrameOffset(nsIFrame
        mCachedOffsetForFrame->mLastCaretFrame = aFrame;
        mCachedOffsetForFrame->mLastContentOffset = inOffset;
      }
   }
 
   return rv;
 }
 
-NS_IMETHODIMP
-Selection::GetAncestorLimiter(nsIContent** aContent)
+nsIContent*
+Selection::GetAncestorLimiter() const
 {
   if (mFrameSelection) {
-    nsCOMPtr<nsIContent> c = mFrameSelection->GetAncestorLimiter();
-    c.forget(aContent);
-  }
-  return NS_OK;
+    return mFrameSelection->GetAncestorLimiter();
+  }
+  return nullptr;
 }
 
-NS_IMETHODIMP
-Selection::SetAncestorLimiter(nsIContent* aContent)
+void
+Selection::SetAncestorLimiter(nsIContent* aLimiter)
 {
   if (mFrameSelection) {
     RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
-    frameSelection->SetAncestorLimiter(aContent);
-  }
-  return NS_OK;
+    frameSelection->SetAncestorLimiter(aLimiter);
+  }
 }
 
 RangeData*
 Selection::FindRangeData(nsIDOMRange* aRange)
 {
   NS_ENSURE_TRUE(aRange, nullptr);
   for (uint32_t i = 0; i < mRanges.Length(); i++) {
     if (mRanges[i].mRange == aRange)
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -357,16 +357,20 @@ public:
   /**
    * Set the painting style for the range. The range must be a range in
    * the selection. The textRangeStyle will be used by text frame
    * when it is painting the selection.
    */
   nsresult SetTextRangeStyle(nsRange* aRange,
                              const TextRangeStyle& aTextRangeStyle);
 
+  // Methods to manipulate our mFrameSelection's ancestor limiter.
+  nsIContent* GetAncestorLimiter() const;
+  void SetAncestorLimiter(nsIContent* aLimiter);
+
 private:
   friend class ::nsAutoScrollTimer;
 
   // Note: DoAutoScroll might destroy arbitrary frames etc.
   nsresult DoAutoScroll(nsIFrame* aFrame, nsPoint aPoint);
 
   // We are not allowed to be in nodes whose root is not our document
   bool HasSameRoot(nsINode& aNode);
--- a/dom/base/nsISelectionPrivate.idl
+++ b/dom/base/nsISelectionPrivate.idl
@@ -26,18 +26,16 @@ struct ScrollAxis;
 [ptr] native RangeArray(nsTArray<nsRange*>);
 [ref] native nsPointRef(nsPoint);
 native nsDirection(nsDirection);
 native ScrollAxis(nsIPresShell::ScrollAxis);
 
 [uuid(0c9f4f74-ee7e-4fe9-be6b-0ba856368178)]
 interface nsISelectionPrivate : nsISupports
 {
-    [noscript] attribute nsIContent ancestorLimiter;
-
     DOMString  toStringWithFormat(in string formatType, in unsigned long flags, in int32_t wrapColumn);
     void  addSelectionListener(in nsISelectionListener newListener);
     void  removeSelectionListener(in nsISelectionListener listenerToRemove);
 
     /* canCacheFrameOffset
      * Frame Offset cache can be used just during calling nsEditor::EndPlaceHolderTransaction.
      * EndPlaceHolderTransaction will give rise to reflow/refreshing view/scroll, and call times
      * of nsTextFrame::GetPointFromOffset whose return value is to be cached.
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -265,21 +265,17 @@ ContentEventHandler::InitRootContent(Sel
   // selection is typically has at least one range but the other selections
   // not so.  If there is a range, computing its root is easy, but if
   // there are no ranges, we need to use ancestor limit instead.
   MOZ_ASSERT(aNormalSelection->Type() == SelectionType::eNormal);
 
   if (!aNormalSelection->RangeCount()) {
     // If there is no selection range, we should compute the selection root
     // from ancestor limiter or root content of the document.
-    nsresult rv =
-      aNormalSelection->GetAncestorLimiter(getter_AddRefs(mRootContent));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return NS_ERROR_FAILURE;
-    }
+    mRootContent = aNormalSelection->GetAncestorLimiter();
     if (!mRootContent) {
       mRootContent = mDocument->GetRootElement();
       if (NS_WARN_IF(!mRootContent)) {
         return NS_ERROR_NOT_AVAILABLE;
       }
     }
     return NS_OK;
   }
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3537,18 +3537,17 @@ HTMLEditor::SelectAll()
   nsINode* anchorNode = selection->GetAnchorNode();
   if (NS_WARN_IF(!anchorNode) || NS_WARN_IF(!anchorNode->IsContent())) {
     return NS_ERROR_FAILURE;
   }
 
   nsIContent* anchorContent = anchorNode->AsContent();
   nsIContent* rootContent;
   if (anchorContent->HasIndependentSelection()) {
-    nsresult rv = selection->SetAncestorLimiter(nullptr);
-    NS_ENSURE_SUCCESS(rv, rv);
+    selection->SetAncestorLimiter(nullptr);
     rootContent = mRootElement;
   } else {
     nsCOMPtr<nsIPresShell> ps = GetPresShell();
     rootContent = anchorContent->GetSelectionRootContent(ps);
   }
 
   NS_ENSURE_TRUE(rootContent, NS_ERROR_UNEXPECTED);