1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef mozilla_dom_ScrollBoxObject_h
7 #define mozilla_dom_ScrollBoxObject_h
8 
9 #include "mozilla/dom/BoxObject.h"
10 #include "Units.h"
11 
12 class nsIScrollableFrame;
13 struct nsRect;
14 
15 namespace mozilla {
16 namespace dom {
17 
18 class ScrollBoxObject final : public BoxObject
19 {
20 public:
21   ScrollBoxObject();
22 
23   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
24 
25   virtual nsIScrollableFrame* GetScrollFrame();
26 
27   void ScrollTo(int32_t x, int32_t y, ErrorResult& aRv);
28   void ScrollBy(int32_t dx, int32_t dy, ErrorResult& aRv);
29   void ScrollByLine(int32_t dlines, ErrorResult& aRv);
30   void ScrollByIndex(int32_t dindexes, ErrorResult& aRv);
31   void ScrollToLine(int32_t line, ErrorResult& aRv);
32   void ScrollToElement(Element& child, ErrorResult& aRv);
33   void ScrollToIndex(int32_t index, ErrorResult& aRv);
34   int32_t GetPositionX(ErrorResult& aRv);
35   int32_t GetPositionY(ErrorResult& aRv);
36   int32_t GetScrolledWidth(ErrorResult& aRv);
37   int32_t GetScrolledHeight(ErrorResult& aRv);
38   void EnsureElementIsVisible(Element& child, ErrorResult& aRv);
39   void EnsureIndexIsVisible(int32_t index, ErrorResult& aRv);
40   void EnsureLineIsVisible(int32_t line, ErrorResult& aRv);
41 
42   // Deprecated APIs from old IDL
43   void GetPosition(JSContext* cx,
44                    JS::Handle<JSObject*> x,
45                    JS::Handle<JSObject*> y,
46                    ErrorResult& aRv);
47 
48   void GetScrolledSize(JSContext* cx,
49                        JS::Handle<JSObject*> width,
50                        JS::Handle<JSObject*> height,
51                        ErrorResult& aRv);
52 
53 protected:
54   void GetScrolledSize(nsRect& aRect, ErrorResult& aRv);
55   void GetPosition(CSSIntPoint& aPos, ErrorResult& aRv);
56 
57 private:
58   ~ScrollBoxObject();
59 };
60 
61 } // namespace dom
62 } // namespace mozilla
63 
64 #endif // mozilla_dom_ScrollBoxObject_h
65