Bug 1387143 part 18. Remove ScrollIntoView bits from nsISelectionPrivate. r=mats
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 08 May 2018 13:52:38 -0400
changeset 417446 aa7dc2628f1213f6fb3fb3b45dc681ae7b79abcb
parent 417445 146396f37e7d030a5b4fb904dc9ccf885f75e252
child 417447 a80dee62407afee16adf2b8093eb468f262cbe68
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 18. Remove ScrollIntoView bits from nsISelectionPrivate. r=mats
accessible/base/nsCoreUtils.cpp
dom/base/Selection.cpp
dom/base/nsISelectionPrivate.idl
dom/events/ContentEventHandler.cpp
dom/webidl/Selection.webidl
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -14,17 +14,16 @@
 #include "nsIBoxObject.h"
 #include "nsXULElement.h"
 #include "mozilla/dom/BoxObject.h"
 #include "nsIDocShell.h"
 #include "nsIObserverService.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIScrollableFrame.h"
-#include "nsISelectionPrivate.h"
 #include "nsISelectionController.h"
 #include "nsISimpleEnumerator.h"
 #include "mozilla/dom/TouchEvent.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TouchEvents.h"
@@ -266,23 +265,22 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame*
 
   nsCOMPtr<nsISelectionController> selCon;
   aFrame->GetSelectionController(presContext, getter_AddRefs(selCon));
   NS_ENSURE_TRUE(selCon, NS_ERROR_FAILURE);
 
   RefPtr<dom::Selection> selection =
     selCon->GetSelection(nsISelectionController::SELECTION_ACCESSIBILITY);
 
-  nsCOMPtr<nsISelectionPrivate> privSel(do_QueryObject(selection));
   selection->RemoveAllRanges(IgnoreErrors());
   selection->AddRange(*aRange, IgnoreErrors());
 
-  privSel->ScrollIntoViewInternal(
-    nsISelectionController::SELECTION_ANCHOR_REGION,
-    true, aVertical, aHorizontal);
+  selection->ScrollIntoView(nsISelectionController::SELECTION_ANCHOR_REGION,
+                            aVertical, aHorizontal,
+                            Selection::SCROLL_SYNCHRONOUS);
 
   selection->CollapseToStart();
 
   return NS_OK;
 }
 
 void
 nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -3377,50 +3377,31 @@ Selection::PostScrollSelectionIntoViewEv
 
   mScrollEvent =
     new ScrollSelectionIntoViewEvent(this, aRegion, aVertical, aHorizontal,
                                      aFlags);
   refreshDriver->AddEarlyRunner(mScrollEvent.get());
   return NS_OK;
 }
 
-NS_IMETHODIMP
-Selection::ScrollIntoView(SelectionRegion aRegion, bool aIsSynchronous,
-                          int16_t aVPercent, int16_t aHPercent)
-{
-  ErrorResult result;
-  ScrollIntoView(aRegion, aIsSynchronous, aVPercent, aHPercent, result);
-  if (result.Failed()) {
-    return result.StealNSResult();
-  }
-  return NS_OK;
-}
-
 void
 Selection::ScrollIntoView(int16_t aRegion, bool aIsSynchronous,
                           int16_t aVPercent, int16_t aHPercent,
                           ErrorResult& aRv)
 {
-  nsresult rv = ScrollIntoViewInternal(aRegion, aIsSynchronous,
-                                       nsIPresShell::ScrollAxis(aVPercent),
-                                       nsIPresShell::ScrollAxis(aHPercent));
+  int32_t flags = aIsSynchronous ? Selection::SCROLL_SYNCHRONOUS : 0;
+  nsresult rv = ScrollIntoView(aRegion,
+                               nsIPresShell::ScrollAxis(aVPercent),
+                               nsIPresShell::ScrollAxis(aHPercent),
+                               flags);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 }
 
-NS_IMETHODIMP
-Selection::ScrollIntoViewInternal(SelectionRegion aRegion, bool aIsSynchronous,
-                                  nsIPresShell::ScrollAxis aVertical,
-                                  nsIPresShell::ScrollAxis aHorizontal)
-{
-  return ScrollIntoView(aRegion, aVertical, aHorizontal,
-                        aIsSynchronous ? Selection::SCROLL_SYNCHRONOUS : 0);
-}
-
 nsresult
 Selection::ScrollIntoView(SelectionRegion aRegion,
                           nsIPresShell::ScrollAxis aVertical,
                           nsIPresShell::ScrollAxis aHorizontal,
                           int32_t aFlags)
 {
   if (!mFrameSelection)
     return NS_OK;//nothing to do
--- a/dom/base/nsISelectionPrivate.idl
+++ b/dom/base/nsISelectionPrivate.idl
@@ -27,53 +27,16 @@ struct ScrollAxis;
 [ref] native nsPointRef(nsPoint);
 native nsDirection(nsDirection);
 native ScrollAxis(nsIPresShell::ScrollAxis);
 
 [uuid(0c9f4f74-ee7e-4fe9-be6b-0ba856368178)]
 interface nsISelectionPrivate : nsISupports
 {
     /**
-     * Scrolls a region of the selection, so that it is visible in
-     * the scrolled view.
-     *
-     * @param aRegion - the region inside the selection to scroll into view
-     *                  (see selection region constants defined in
-     *                   nsISelectionController).
-     * @param aIsSynchronous - when true, scrolls the selection into view
-     *                         before returning. If false, posts a request which
-     *                         is processed at some point after the method returns.
-     * @param aVPercent - how to align the frame vertically.
-     * @param aHPercent - how to align the frame horizontally.
-     */
-    void scrollIntoView(in short aRegion, in boolean aIsSynchronous,
-                        in int16_t aVPercent,
-                        in int16_t aHPercent);
-
-    /**
-     * Scrolls a region of the selection, so that it is visible in
-     * the scrolled view.
-     *
-     * @param aRegion - the region inside the selection to scroll into view
-     *                  (see selection region constants defined in
-     *                   nsISelectionController).
-     * @param aIsSynchronous - when true, scrolls the selection into view
-     *                         before returning. If false, posts a request which
-     *                         is processed at some point after the method returns.
-     * @param aVertical - how to align the frame vertically and when.
-     *                    See nsIPresShell.h:ScrollAxis for details.
-     * @param aHorizontal - how to align the frame horizontally and when.
-     *                    See nsIPresShell.h:ScrollAxis for details.
-     */
-    [noscript] void scrollIntoViewInternal(in short aRegion,
-                                           in boolean aIsSynchronous,
-                                           in ScrollAxis aVertical,
-                                           in ScrollAxis aHorizontal);
-
-    /**
      * Modifies the cursor Bidi level after a change in keyboard direction
      * @param langRTL is PR_TRUE if the new language is right-to-left or
      *                PR_FALSE if the new language is left-to-right.
      */
     [noscript] void selectionLanguageChange(in boolean langRTL);
 
     /**
      * setColors() sets custom colors for the selection.
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -3179,19 +3179,19 @@ ContentEventHandler::OnSelectionEvent(Wi
     }
   }
 
   // Pass the eSetSelection events reason along with the BatchChange-end
   // selection change notifications.
   mSelection->EndBatchChanges(aEvent->mReason);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mSelection->ScrollIntoViewInternal(
+  mSelection->ScrollIntoView(
     nsISelectionController::SELECTION_FOCUS_REGION,
-    false, nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis());
+    nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis(), 0);
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsRect
 ContentEventHandler::FrameRelativeRect::RectRelativeTo(
                                           nsIFrame* aDestFrame) const
 {
--- a/dom/webidl/Selection.webidl
+++ b/dom/webidl/Selection.webidl
@@ -101,16 +101,29 @@ partial interface Selection {
 
   /**
    * Return array of ranges intersecting with the given DOM interval.
    */  
   [ChromeOnly,Throws,Pref="dom.testing.selection.GetRangesForInterval"]
   sequence<Range> GetRangesForInterval(Node beginNode, long beginOffset, Node endNode, long endOffset,
                                        boolean allowAdjacent);
 
+  /**
+   * Scrolls a region of the selection, so that it is visible in
+   * the scrolled view.
+   *
+   * @param aRegion the region inside the selection to scroll into view
+   *                (see selection region constants defined in
+   *                nsISelectionController).
+   * @param aIsSynchronous when true, scrolls the selection into view
+   *                       before returning. If false, posts a request which
+   *                       is processed at some point after the method returns.
+   * @param aVPercent how to align the frame vertically.
+   * @param aHPercent how to align the frame horizontally.
+   */
   [ChromeOnly,Throws]
   void scrollIntoView(short aRegion, boolean aIsSynchronous, short aVPercent, short aHPercent);
 
   [ChromeOnly,Throws]
   void setColors(DOMString aForegroundColor, DOMString aBackgroundColor,
                  DOMString aAltForegroundColor, DOMString aAltBackgroundColor);
 
   [ChromeOnly,Throws]