Bug 1465866: removes methods from ScrollBoxObject and deletes unneccessary spacing r=bz+6102
authorEmma Malysz <emalysz@mozilla.com>
Fri, 01 Jun 2018 12:44:26 -0700
changeset 424888 058b07756df6e4e2530aa1847936dae16dddd58c
parent 424887 66956b121b939bf9a56bc33d6f3b8ffa58df4131
child 424889 f5bfc9971285d5edcf12e4610d521eb4bedf7a59
push id34226
push userrgurzau@mozilla.com
push dateWed, 04 Jul 2018 09:57:31 +0000
treeherdermozilla-central@3d7f2fdc5bf7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1465866
milestone63.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 1465866: removes methods from ScrollBoxObject and deletes unneccessary spacing r=bz+6102 MozReview-Commit-ID: GrwTPJYai6O
dom/webidl/ScrollBoxObject.webidl
layout/xul/ScrollBoxObject.cpp
layout/xul/ScrollBoxObject.h
--- a/dom/webidl/ScrollBoxObject.webidl
+++ b/dom/webidl/ScrollBoxObject.webidl
@@ -18,53 +18,28 @@ interface ScrollBoxObject : BoxObject {
 
   /**
    * Scroll the given amount of device pixels to the right and down.
    * Values will be clamped to make the resuling position legal.
    */
   [Throws]
   void scrollBy(long dx, long dy);
   [Throws]
-  void scrollByLine(long dlines);
-  [Throws]
   void scrollByIndex(long dindexes);
   [Throws]
-  void scrollToLine(long line);
-  [Throws]
   void scrollToElement(Element child);
-  [Throws]
-  void scrollToIndex(long index);
 
   /**
    * Get the current scroll position in css pixels.
    * @see scrollTo for the definition of x and y.
    */
   [Pure, Throws]
   readonly attribute long positionX;
   [Pure, Throws]
   readonly attribute long positionY;
   [Pure, Throws]
   readonly attribute long scrolledWidth;
   [Pure, Throws]
   readonly attribute long scrolledHeight;
 
-  /**
-   * DEPRECATED: Please use positionX and positionY
-   *
-   * Get the current scroll position in css pixels.
-   * @see scrollTo for the definition of x and y.
-   */
-  [Throws]
-  void getPosition(object x, object y);
-
-  /**
-   * DEPRECATED: Please use scrolledWidth and scrolledHeight
-   */
-  [Throws]
-  void getScrolledSize(object width, object height);
-
   [Throws]
   void ensureElementIsVisible(Element child);
-  [Throws]
-  void ensureIndexIsVisible(long index);
-  [Throws]
-  void ensureLineIsVisible(long line);
 };
--- a/layout/xul/ScrollBoxObject.cpp
+++ b/layout/xul/ScrollBoxObject.cpp
@@ -54,28 +54,16 @@ void ScrollBoxObject::ScrollBy(int32_t d
 
   if (aRv.Failed()) {
     return;
   }
 
   ScrollTo(pt.x + dx, pt.y + dy, aRv);
 }
 
-void ScrollBoxObject::ScrollByLine(int32_t dlines, ErrorResult& aRv)
-{
-  nsIScrollableFrame* sf = GetScrollFrame();
-  if (!sf) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  sf->ScrollBy(nsIntPoint(0, dlines), nsIScrollableFrame::LINES,
-               nsIScrollableFrame::SMOOTH);
-}
-
 // XUL <scrollbox> elements have a single box child element.
 // Get a pointer to that box.
 // Note that now that the <scrollbox> is just a regular box
 // with 'overflow:hidden', the boxobject's frame is an nsXULScrollFrame,
 // the <scrollbox>'s box frame is the scrollframe's "scrolled frame", and
 // the <scrollbox>'s child box is a child of that.
 static nsIFrame* GetScrolledBox(BoxObject* aScrollBox) {
   nsIFrame* frame = aScrollBox->GetFrame(false);
@@ -207,30 +195,16 @@ void ScrollBoxObject::ScrollByIndex(int3
        sf->ScrollTo(pt, nsIScrollableFrame::INSTANT, &range);
    } else {
        // Use a destination range that ensures the top edge will be visible.
        nsRect range(cp.x, rect.y - csspixel, 0, csspixel);
        sf->ScrollTo(nsPoint(cp.x, rect.y), nsIScrollableFrame::INSTANT, &range);
    }
 }
 
-void ScrollBoxObject::ScrollToLine(int32_t line, ErrorResult& aRv)
-{
-  nsIScrollableFrame* sf = GetScrollFrame();
-  if (!sf) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  nscoord y = sf->GetLineScrollAmount().height * line;
-  nsRect range(0, y - nsPresContext::CSSPixelsToAppUnits(1),
-               0, nsPresContext::CSSPixelsToAppUnits(1));
-  sf->ScrollTo(nsPoint(0, y), nsIScrollableFrame::INSTANT, &range);
-}
-
 void ScrollBoxObject::ScrollToElement(Element& child, ErrorResult& aRv)
 {
   nsCOMPtr<nsIPresShell> shell = GetPresShell(false);
   if (!shell) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
@@ -240,21 +214,16 @@ void ScrollBoxObject::ScrollToElement(El
                                  nsIPresShell::SCROLL_ALWAYS),
                                nsIPresShell::ScrollAxis(
                                  nsIPresShell::SCROLL_LEFT,
                                  nsIPresShell::SCROLL_ALWAYS),
                                nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY |
                                nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
 
-void ScrollBoxObject::ScrollToIndex(int32_t index, ErrorResult& aRv)
-{
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-}
-
 int32_t ScrollBoxObject::GetPositionX(ErrorResult& aRv)
 {
   CSSIntPoint pt;
   GetPosition(pt, aRv);
   return pt.x;
 }
 
 int32_t ScrollBoxObject::GetPositionY(ErrorResult& aRv)
@@ -299,86 +268,33 @@ void ScrollBoxObject::GetScrolledSize(ns
       return;
     }
 
     aRect = scrolledBox->GetRect();
     aRect.width  = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
     aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
 }
 
-void ScrollBoxObject::GetPosition(JSContext* cx,
-                                  JS::Handle<JSObject*> x,
-                                  JS::Handle<JSObject*> y,
-                                  ErrorResult& aRv)
-{
-  CSSIntPoint pt;
-  GetPosition(pt, aRv);
-  JS::Rooted<JS::Value> v(cx);
-  if (!ToJSValue(cx, pt.x, &v) ||
-      !JS_SetProperty(cx, x, "value", v)) {
-    aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
-    return;
-  }
-  if (!ToJSValue(cx, pt.y, &v) ||
-      !JS_SetProperty(cx, y, "value", v)) {
-    aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
-    return;
-  }
-}
-
-void ScrollBoxObject::GetScrolledSize(JSContext* cx,
-                                      JS::Handle<JSObject*> width,
-                                      JS::Handle<JSObject*> height,
-                                      ErrorResult& aRv)
-{
-  nsRect rect;
-  GetScrolledSize(rect, aRv);
-  JS::Rooted<JS::Value> v(cx);
-  if (!ToJSValue(cx, rect.width, &v) ||
-      !JS_SetProperty(cx, width, "value", v)) {
-    aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
-    return;
-  }
-  if (!ToJSValue(cx, rect.height, &v) ||
-      !JS_SetProperty(cx, height, "value", v)) {
-    aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
-    return;
-  }
-}
-
 void ScrollBoxObject::EnsureElementIsVisible(Element& child, ErrorResult& aRv)
 {
     nsCOMPtr<nsIPresShell> shell = GetPresShell(false);
     if (!shell) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return;
     }
 
     shell->ScrollContentIntoView(&child,
                                  nsIPresShell::ScrollAxis(),
                                  nsIPresShell::ScrollAxis(),
                                  nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY |
                                  nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
-
-void ScrollBoxObject::EnsureIndexIsVisible(int32_t index, ErrorResult& aRv)
-{
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-}
-
-void ScrollBoxObject::EnsureLineIsVisible(int32_t line, ErrorResult& aRv)
-{
-  aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
-}
-
 } // namespace dom
 } // namespace mozilla
 
-// Creation Routine ///////////////////////////////////////////////////////////////////////
-
 using namespace mozilla::dom;
 
 nsresult
 NS_NewScrollBoxObject(nsIBoxObject** aResult)
 {
-  NS_ADDREF(*aResult = new ScrollBoxObject());
-  return NS_OK;
+    NS_ADDREF(*aResult = new ScrollBoxObject());
+    return NS_OK;
 }
--- a/layout/xul/ScrollBoxObject.h
+++ b/layout/xul/ScrollBoxObject.h
@@ -22,39 +22,24 @@ public:
   ScrollBoxObject();
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   virtual nsIScrollableFrame* GetScrollFrame();
 
   void ScrollTo(int32_t x, int32_t y, ErrorResult& aRv);
   void ScrollBy(int32_t dx, int32_t dy, ErrorResult& aRv);
-  void ScrollByLine(int32_t dlines, ErrorResult& aRv);
   void ScrollByIndex(int32_t dindexes, ErrorResult& aRv);
-  void ScrollToLine(int32_t line, ErrorResult& aRv);
   void ScrollToElement(Element& child, ErrorResult& aRv);
-  void ScrollToIndex(int32_t index, ErrorResult& aRv);
   int32_t GetPositionX(ErrorResult& aRv);
   int32_t GetPositionY(ErrorResult& aRv);
   int32_t GetScrolledWidth(ErrorResult& aRv);
   int32_t GetScrolledHeight(ErrorResult& aRv);
   void EnsureElementIsVisible(Element& child, ErrorResult& aRv);
-  void EnsureIndexIsVisible(int32_t index, ErrorResult& aRv);
-  void EnsureLineIsVisible(int32_t line, ErrorResult& aRv);
 
-  // Deprecated APIs from old IDL
-  void GetPosition(JSContext* cx,
-                   JS::Handle<JSObject*> x,
-                   JS::Handle<JSObject*> y,
-                   ErrorResult& aRv);
-
-  void GetScrolledSize(JSContext* cx,
-                       JS::Handle<JSObject*> width,
-                       JS::Handle<JSObject*> height,
-                       ErrorResult& aRv);
 
 protected:
   void GetScrolledSize(nsRect& aRect, ErrorResult& aRv);
   void GetPosition(CSSIntPoint& aPos, ErrorResult& aRv);
 
 private:
   ~ScrollBoxObject();
 };